Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / March 2004

Tip: Looking for answers? Try searching our database.

Thread sleep problem

Thread view: 
Rob Dann - 06 Mar 2004 16:41 GMT
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...



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.