473,320 Members | 1,988 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Display a frame N times // Desplegar una ventana N veces

Osoascam
Hi!
Well, this is my question.
I have a Chinesse Checkers game, so there's a comboBox to choose number of players. A global variable named numJug (number Of Players) gets that number. So far, so good.

The problem starts when you click "Accept" on that window, as it calls N times (numJug times) the window for chosing the color for every player. The thing is, it doesn't work. For 6 players, the window only appears for 1, 1, 3 and 5. (But it seems to be doing it the 6 times, I'll explain later).

So, the event for the "Accept" button after selecting the number of players is

Expand|Select|Wrap|Line Numbers
  1. colorEvents(jugActual);
jugActual (Current Player) starts on 1, and is the... well, the current player whose color is being chosen.

Then, the window for chosing colors appear. What it does is something like this:

Expand|Select|Wrap|Line Numbers
  1. public void eventoColores(int jugador) //jugador is the current player
  2.     {
  3.        // The creation of the window
  4.        frameColores.setSize(200, 230);
  5.        frameColores.setLocationRelativeTo(null);
  6.        frameColores.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  7.        frameColores.setResizable(true);
  8.        frameColores.setLayout(new BorderLayout());
  9.  
  10.        // cantJug is a Label, it changes showing the current player
  11.        JPanel panelRadio = new JPanel(new GridLayout(0, 1));
  12.        cantJug.setText("Pick the color for player "+jugador+"\n");
  13.  
  14.        // ActionListener for the buttons on the ComboBox
  15.        ButtonGroup Colores = new ButtonGroup();
  16.        botonRojo.addActionListener(this);
  17.        botonRojo.setSelected(true);
  18.        botonVerde.addActionListener(this);
  19.        .
  20.        .
  21.        .
  22.  
  23.        // Buttons are added to the ButtonGroup
  24.        Colores.add(botonRojo);
  25.        .
  26.        .
  27.        .
  28.  
  29.        // Buttons added to a panel
  30.        panelRadio.add(botonRojo);
  31.        .
  32.        .
  33.        .
  34.  
  35.       // Components are placed on frameColores
  36.        frameColores.add(cantJug, BorderLayout.PAGE_START);
  37.        frameColores.add(panelRadio, BorderLayout.LINE_START);
  38.        frameColores.add(dibuColor, BorderLayout.CENTER);
  39.        frameColores.add(aceptaColores, BorderLayout.PAGE_END);
  40.  
  41.        frameColores.setVisible(true);
  42.  
  43.  
  44.     }
It works, nicely. The thing is, that window has an Accept button, whose event is (and I believe that's where the problem is):

Expand|Select|Wrap|Line Numbers
  1. if (jugActual < numJug)
  2.    eventoColores(jugActual++);
jugActual is, as I said, the current player, and numJug, the number of players, so if you're working wiht player 6, and there are 6 players, you're done. If not, it calls the event eventoColores, which, as you saw, displays the window and everything.

I put a System.out.println(jugActual), and it prints 1-2-3-4-5-6, if there are six players, so the cycle is correctly done. What i think the problem is... is that the windows are not being shown, as they don't wait until the other one is closed, so the just "pop" (is only one window that is shown several times, so...)

Please... heeeeeeeeelp!!! (T_T)
Apr 7 '07 #1
2 1417
Somebody?
Please, this thing is freaking me out!! T_T
Apr 7 '07 #2
Another thing I noticed...
If I put, ont he button "Accept" to call eventoColores (or colorEvents, I changed the name in here for it to be in English), the windows appear for player 1,2,4,8,16... you get the picture...

Why is that?
What can I do?

Also, everything appears, except some combo Buttons...

While I was writing this, the answer came... I will write what I did, it may help you. The addActionListener(this) was within the method called eventoColores. I changed it to another part of the code and it worked... Can enybody explain me why?

Another thing... The radio buttons are displayed only once... The second, third... times, you have to pass the mouse above them for them to be repainted. How do I do that?

Thanks in advance
:D
:)
Apr 7 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: exolon | last post by:
Yes is it possible to display a layer above an other frame than the one the layer come from ?!? thanks ;)
8
by: Yves PEYSSON | last post by:
Hi, I want to display the same image (from the same file) at different positions in a window. Up to now I used DIV command in the body part of the text, and document.getElementById in order to...
2
by: William Gill | last post by:
I need to display a couple of labels and a checkbox from each entry in my database. Simple enough, but there are several hundred records, and I only want to display 5 or 10 at a time. Can this be...
17
by: kimimaro | last post by:
How do you limits employee display where you enter the department for all the employee within that department be displayed and if lets say they are 100 or so and you have to limits 10 employee per...
3
by: rajarya | last post by:
Hi, I m designing a HTML page(index.html),here i have 2 frames,by defult both frames have index1.html and index2.html as their source . in first frame(index.html) ,i have some redio buttons,and a...
0
by: adubra | last post by:
Hi there, I am using a device context (DC) and a buffer to successfully draw to screen. However, when I update the DC at very high frame rate and drag the frame containing the image very quickly...
4
by: ArrK | last post by:
I want to use a control frame to create and/or modify the content (images and text) of a display frame - all files and images are client side. . When I try to write to the display frame from the...
2
by: Abneo | last post by:
Hi all, I am very new to Javascript and I am in some need of some help. I am creating a site that has a madlib. I got the madlib code but now I want the results of the madlib to display in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.