views:

144

answers:

1

I'm creating a simple java game Applet that has multiple Panels, The main game Panel has 4 JButtons that lead to the rest of the Panels when they are clicked.

when the program runs, the four Panels are initialized 1st inside the init(), and inside each Panel initialization, I made all the Jcomponents invisible but only the main applet.

lets say there is a JButton in the main Applet Called start, when it's pressed, i need to set all the main JButtons to invisible, and set the sub Panel to visible but it's not working for me, I used everything I could think of, like repaint() or UpdateUI() but still not working.

any suggestions would be much appreciated.

Cheers

+1  A: 

First, ensure all creation is performed not in init(), but in the EDT, see the tutorial. If you have an ampty start() method I'd recommend you use invokeLater in the init() (instead of the tutorial recommendation of invokeAndWait).

To hide buttons simply call setVisible on the JButton. There should be no need to ask for a repaint afterwards.

Further analysis is difficult without seeing the code.

Pool