• 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

Avoid flickering

 
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
how can we avoid flickering of the applet when displaying an animation ?
regards
raghav mathur
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
example code
further explanation
Good Luck.
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Got the point ! THANKS A TON Dirk , Marilyn & Mika
regards
raghav mathur...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic