Previous | Next | Trail Map | Creating a User Interface (with Swing) | Working with Graphics

Eliminating Flashing

The flashing that you might have noticed in the example on the previous page is a common problem with animation (and occasionally with static graphics). The flashing effect is the result of two facts: You can use two techniques to eliminate flashing: overriding the update() method and implementing double buffering.

Overriding the update() Method

To eliminate flashing, whether or not you use double buffering, you must override the update() method. This is necessary because it's the only way to prevent the entire background of the Component from being cleared every time the Component is drawn.

Implementing Double Buffering

Double buffering involves performing multiple graphics operations on an undisplayed graphics buffer, and then displaying the resulting image onscreen. Double buffering prevents incomplete images from being drawn to the screen.


Previous | Next | Trail Map | Creating a User Interface (with Swing) | Working with Graphics