This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes update and repaint Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "update and repaint" Watch "update and repaint" New topic
Author

update and repaint

Rich Wright
Greenhorn

Joined: Oct 08, 1999
Posts: 17
I'm a little confused about update() and repaint(). If you need to refresh part of the screen that was hidden by another window would you call the repaint() method (The repaint() method would schedule a call to the update() method).
Thanks for your help
Pawel Veselov
Ranch Hand

Joined: Jan 14, 1999
Posts: 165
You are correct.
The difference between update() and repaint() is that update has Graphics instance as an argument, so it does know where to draw on.
repaint() is a empty scheduler, that doesn't make a repaint. This allow you to call repaint() and continue execution. The update() will be called in another thread (AWT-Motif, if I am not mistaken)
To repaint piece of a component, you can use repaint(int, int, int, int). In that case, update() will received clipped Graphics.

------------------
With best of best regards, Pawel S. Veselov ( aka Black Angel )

With best of best regards, Pawel S. Veselov ( aka Black Angel )
 
GeeCON Prague 2014
 
subject: update and repaint