Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 12. Graphics > Advanced Animation

12.15. Advanced Animation

Way back in Example 12-4, we saw a simple animation technique that suffered, unfortunately, from flickering. Example 12-19 is a program that performs a more graphics-intensive animation but doesn't flicker, because it uses a technique known as double-buffering : it draws each frame of the animation off-screen, then copies the frame onto the screen all at once. This example also has better performance because it requests redraws of only the relatively small portion of the screen that needs to be redrawn.

Another interesting feature of this example is its use of the javax.swing.Timer class to call the actionPerformed( ) method of a specified ActionListener object at specified intervals. The Timer class is used here so that you don't have to create a Thread. (Note that Java 1.3 includes java.util.Timer, a class that is similar to, but quite distinct from, javax.swing.Timer.)


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint