Flickering in Applets and its Solution
Unless you are careful, dynamic applets will give flickering screens (in the regular AWT, not in Swing set).
This is due to the cycle
- repaint()
- update(g) clearing screen
- paint(g) drawing new screen .....
- where flicker is caused by the rapid clear-paint cycle.
There are two ways to solve this problem which involve changing update() in different ways
- 1: Change update() either not to clear screen at all (because you know paint() will write over parts that are to be changed) or to just clear the parts of the screen that are changed
- or 2:Double Buffering