• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, thanks for the help, I will try implementing them and let you know how it goes!
reply
    Bookmark Topic Watch Topic
  • New Topic