File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes paint 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 "paint" Watch "paint" New topic


fraternity lawson

Joined: Mar 11, 2001
Posts: 26
An AWT GUI under exposure condition,which one or more method will b
e invok when it redraw?
A.paint(); B.update(); C.repaint(); D.drawing();
I think repaint will call update which in turn will call paint().Do let me know if am wrong.
Ash sav
Ranch Hand

Joined: Apr 14, 2001
Posts: 55
I think update() and repaint()
Tracy Qi
Ranch Hand

Joined: Apr 23, 2001
Posts: 37
update (): which clears the component to its back ground color and then calls paint().
repaint (): this method schedules a call to the update() method. This entire mean is that a request flag is set in the GUI thread. Every 100 milliseconds the GUI thread checks the flag. No matter how many requests are made during any 100 milliseconds only a single call is made to update ().
The call to the repaint () method ends immediately. The call to the repaint () method only schedules a repainting of the component. AWT thread should eventually call the update () method to perform the actual repainting of the component.
The repaint() method is overloaded. The no-args version of repaint() does not cause your user interface to repaint right away. In fact, when repaint() returns, your component has not yet been repainted - you��ve only issued a request for a repaint(). There is another version of repaint() that requests the component to be repainted within a certain number of milliseconds.
If not overridden the update method clears the background and calls paint(); By overriding the update method, any previously drawn graphics will not be cleared. This is only a trivial way of preserving any graphics drawn. If the application is resized or the drawing area covered in some way the graphics will be cleared.

Hope this helps.

I agree. Here's the link:
subject: paint
It's not a secret anymore!