• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
zhang lan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11096
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, never call paint(g). Complete a round of calculations and call repaint().
http://java.sun.com/docs/books/tutorial/uiswing/painting/index.html
 
zhang lan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, thanks for the help, I will try implementing them and let you know how it goes!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic