Monday, May 10, 2004 06:56 PM
Typically, you won't call paint() directly. The paint() method is automatically called (in an applet) after the init() has completed. If a window partially covers the applet, paint() is then called to reconstruct the obscured portion. The GUI thread makes these calls
. There are a few other instances where the GUI thread calls paint() as well, like when the window is minimized then restored.
Repaint, on the other hand, is the one a programmer will typically invoke. The repaint() method asynchronously schedules a call to the update() method, which then calls paint(). The reason for the complexity is due to Java's support for concurrent programming.
It's not recommended to call straight to paint() or update()! The UI threads control those methods and calling them directly can cause all sorts of strange behavior, including lockups of the applet.
Hope that helps!