Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

overriding update()

 
Sam
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
Why do we explicitly override update() method when repaint() automatically gives call to update() ? I think, the purpose is that no flickering is there when the output is shown to the appletviewer / browser.
However, when we call repaint() and doesn't explicitly override update() in our program, then what repaint() does, it first clears the screen, i.e., whatever previously drawn on the applet gets cleared and then it calls update() which then calls the paint() method.
But when we explicitly override update() in our program, then what repaint() does is that without clearing what is previously drawn on the applet , it calls update() which in turn calls repaint(). Thus, previously drawn things doesn't get cleared.
If I don't override update(), flickering is there. And if do , previously drawn things doesn't get cleared.
Anyone has the way out ?
Thanx in advance.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!