Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

paint

 
chandan panda
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the reason we call repaint() method to repaint the screen instead of calling paint() method?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Welcome to JavaRanch!
repaint() tells the JVM to schedule a screen paint for a convenient time; for example, when the CPU isn't too busy with something else. It also can "coalesce" paint requests, which means you can call repaint() 500 times in a row without forcing the screen to be repainted 500 times; requests that come close together can be combined into one. Finally, note that repaint() is sending a message to another thread to do the actual painting; this thread is dedicated to the task of doing GUI things, freeing up your application threads to do their own work.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!