paint/repaint
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   mohan_panda
Posted On:   Monday, May 10, 2004 01:00 AM

Can anybody explain me wht is the major difference betn the panit and repaint method with repect of internal working or how the applet intenally paint the images when the mathod r called ????

Re: paint/repaint

Posted By:   Brian_Glodde  
Posted On:   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!

About | Sitemap | Contact