Previous | Next | Trail Map | Creating a User Interface | 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). Flashing is generally more noticeable on PCs than on X Windows-based systems, since X graphics are buffered (which makes the flash shorter). 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 just before 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. Besides preventing incomplete images from being drawn to the screen, double buffering can improve drawing performance because drawing to an offscreen image is more efficient than drawing to the screen.


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