wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Calling paint(g) has no affect during processor intensive activity Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Calling paint(g) has no affect during processor intensive activity" Watch "Calling paint(g) has no affect during processor intensive activity" New topic
Author

Calling paint(g) has no affect during processor intensive activity

zhang lan
Greenhorn

Joined: Feb 23, 2010
Posts: 2
Hi,

I am writing a small game to improve my Java knowledge. When the game setups, a lot of calculations are made and a lot of data is stored to a flat file. This takes about 5 seconds.

Whilst this is happening, I want a message to appear on the screen saying "Please wait".

However, before this message can be displayed properly, the program starts on the calculations. Only when the calculations are finished does the message appear briefly.

Is there a method I can call or a piece of code I can use which checks that the message has been displayed before the processor intensive code is carried out?

Thanks for any help on this matter.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10172
    
    8

Zhang,
Welcome to the Ranch.

Recommended reading http://java.sun.com/docs/books/tutorial/essential/concurrency/
What you need to do is put your computations and screen painting on different threads.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Also, never call paint(g). Complete a round of calculations and call repaint().
http://java.sun.com/docs/books/tutorial/uiswing/painting/index.html


luck, db
There are no new questions, but there may be new answers.
zhang lan
Greenhorn

Joined: Feb 23, 2010
Posts: 2
Hi, thanks for the help, I will try implementing them and let you know how it goes!
 
 
subject: Calling paint(g) has no affect during processor intensive activity
 
Similar Threads
Event Dispatching
Thread priority
Please help - setMnemonic
ArrayList.add() in a for loop, will the order of the items always be the same?
Adding JButton