aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes repaint and update 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 "repaint and update" Watch "repaint and update" New topic
Author

repaint and update

teja nelluri
Greenhorn

Joined: Jun 22, 2000
Posts: 8

hi everybody,

can anybody please exaplain differece between
repaint and update.

thanks
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
teja,
I took the following method descriptions from Java API documentation ( which is free and useful ) for the java.awt.Component class -


repaint
This method causes a call to this component's update method as soon as possible
update
Clears this component by filling it with the background color.
Sets the color of the graphics context to be the foreground color of this component.
Calls this component's paint method to completely redraw this component.
paint
Paints this component. This method is called when the contents of the component should be painted in response to the component first being shown or damage needing repair. The clip rectangle in the Graphics parameter will be set to the area which needs to be painted.

Hence the order of invocation is repaint->update->paint. Marcus Green has a neat acronym to help you remember this ( Thanks Marcus! ) - Really-Ugly-Painting.
It is recommended that you call repaint() instead of update(), unless you have a very compelling reason to do so, since the repaint() schedules a paint to occur while update tries do do it immediately and might make your program resource intensive.
Hope this helps.
Ajith
[This message has been edited by Ajith Kallambella (edited August 01, 2000).]


Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: repaint and update