• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

repaint and update

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

hi everybody,

can anybody please exaplain differece between
repaint and update.

thanks
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic