import java.awt.*; import java.applet.*; class NoFlickerApplet extends Applet { private Image offScreenImage; private Graphics offScreenGraphics; private Dimension offScreenSize; public final void update(Graphics theGraphicsContext){ Dimension dim = this.getSize(); /* size() originally... */ if( (offScreenImage == null) || (dim.width != offScreenSize.width) || (dim.height != offScreenSize.height)) { this.offScreenImage = this.createImage(dim.width, dim.height); this.offScreenSize = dim; this.offScreenGraphics = this.offScreenImage.getGraphics(); } this.offScreenGraphics.clearRect(0, 0, this.offScreenSize.width, this.offScreenSize.height); this.paint(offScreenGraphics); theGraphicsContext.drawImage(this.offScreenImage, 0, 0, null); } }