Hey,
I have a project with three classes in, GAME, GUI and Map
The GUI class is listening to events fired from the GAME class.
The Map class extends JPanel and overrides paint(Graphics g) and is told by
the GUI class what to display and when.
The problem I get occurs when I call a method from the ActionListener of a
JDialog.
The sequence goes:
User clicks "OK" in a modal JDialog in GUI
-->
GUI calls GAME.okpressed() (from inside the actionlistener of the dialog)
GUI disposes dialog.
-->
GAME loop:
Performs operation (math calculation);
Fires event;
Thread.sleep(500);
-->
GUI listens, and calls Map.repaint() each time an event is recieved
For some reason, when the button is pressed, the Map does not repaint until
the GAME class has finished the entire loop.
If I perform the same actions but instead of using a dialog just calling
okpressed() the animation works successfully. So it is the dialog that is
causing trouble, is there anyway to resolve this?
Rob Dann
Knute Johnson - 07 Mar 2004 19:38 GMT
> Hey,
>
[quoted text clipped - 30 lines]
>
> Rob Dann
It's not the dialog but the ActionListener. You are calling sleep in
the EDT. To prove it take out the sleep and see if it works right.

Signature
Knute Johnson
email s/nospam/knute/
Molon labe...