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
- colorEvents(jugActual);
Then, the window for chosing colors appear. What it does is something like this:
Expand|Select|Wrap|Line Numbers
- public void eventoColores(int jugador) //jugador is the current player
- {
- // The creation of the window
- frameColores.setSize(200, 230);
- frameColores.setLocationRelativeTo(null);
- frameColores.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frameColores.setResizable(true);
- frameColores.setLayout(new BorderLayout());
- // cantJug is a Label, it changes showing the current player
- JPanel panelRadio = new JPanel(new GridLayout(0, 1));
- cantJug.setText("Pick the color for player "+jugador+"\n");
- // ActionListener for the buttons on the ComboBox
- ButtonGroup Colores = new ButtonGroup();
- botonRojo.addActionListener(this);
- botonRojo.setSelected(true);
- botonVerde.addActionListener(this);
- .
- .
- .
- // Buttons are added to the ButtonGroup
- Colores.add(botonRojo);
- .
- .
- .
- // Buttons added to a panel
- panelRadio.add(botonRojo);
- .
- .
- .
- // Components are placed on frameColores
- frameColores.add(cantJug, BorderLayout.PAGE_START);
- frameColores.add(panelRadio, BorderLayout.LINE_START);
- frameColores.add(dibuColor, BorderLayout.CENTER);
- frameColores.add(aceptaColores, BorderLayout.PAGE_END);
- frameColores.setVisible(true);
- }
Expand|Select|Wrap|Line Numbers
- if (jugActual < numJug)
- eventoColores(jugActual++);
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)