Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Avoid flickering

 
Raghav Mathur
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
how can we avoid flickering of the applet when displaying an animation ?
regards
raghav mathur
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
double buffering
I'd bet you could turn up a couple of decent explanations by searching this forum, the awt forum, and one or two of the java in general forums. Note: the search page link is at the top right of this page.
Good Luck.
 
Raghav Mathur
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Couldn't find anything valuable .
tried this link http://softwaredev.earthweb.com/java/sdjjavase/article/0,,12395_626541,00.html
but it doesn't seem to open the required page
now what?

Originally posted by Dirk Schreckmann:
double buffering
I'd bet you could turn up a couple of decent explanations by searching this forum, the awt forum, and one or two of the java in general forums. Note: the search page link is at the top right of this page.
Good Luck.
 
Raghav Mathur
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I,am still not getting the idea behind Double Buffering . Please if anybody could explain it to me without giving any URL links .
Thanks in advance
raghav
Originally posted by Mika Hirvasoja:
How about http://www.realapplets.com/tutorial/DoubleBuffering.html

[ May 05, 2002: Message edited by: raghav mathur ]
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The normal operation of repaint() (then update(Graphics) then paint(Graphics)) is to clear the display area then draw it again (probably using new information).
Considering an animation, rather than displaying the new graphics immediately to the user's display from the paint method's automatic Graphics object, the new image is first drawn to an offscreen image. After the new image is drawn, the Graphics object from this offscreen image is then displayed to the user's display through the automatic Graphics object in paint.
To further remove the flickering, the update(Graphics) method should be overridden to avoid the call to clear the display before repainting.
A performance enhancement to consider would be to describe a clipping area where the new graphics will appear (as often the entire display area is not changing during an animation) and repaint this clipping area only.
To paraphrase:
1. draw new graphics to offscreen image
2. get offscreen image's graphics object
3. do not clear the entire display area
4. display this new graphics object
When I get a chance I'll dig out a simple example animation and describe what's going on in it. Otherwise, I'm pretty sure it's posted somewhere in this forum or the awt forum within the past five months.
Good Luck.
 
Dirk Schreckmann
Sheriff
Posts: 7023
 
Marilyn de Queiroz
Sheriff
Posts: 9068
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggest you go to The Code Barn and study
HelloAnimThreadFirst
HelloAnimThreadA
HelloAnimThreadB
HelloAnimThreadC
(Part 4 of 4 - demonstrates simple animation implementing double-buffering for smoother animation)
 
Raghav Mathur
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got the point ! THANKS A TON Dirk , Marilyn & Mika
regards
raghav mathur...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic