import java.awt.*; public class DBFrame extends Frame { private Image offScreenBuffer; private boolean clearFlag = true; public boolean getClearFlag() { return clearFlag;} public void setClearFlag(boolean flag) { clearFlag = flag;} public void update(Graphics g) { Graphics gr; // Will hold the graphics context from the offScreenBuffer. // We need to make sure we keep our offscreen buffer the same size // as the graphics context we're working with. if (offScreenBuffer==null || (! (offScreenBuffer.getWidth(this) == getSize().width && offScreenBuffer.getHeight(this) == getSize().height))) { offScreenBuffer = createImage(getSize().width, getSize().height); } // We need to use our buffer Image as a Graphics object: gr = offScreenBuffer.getGraphics(); // clear old graphics if (clearFlag) gr.clearRect(0,0,getSize().width, getSize().height); paint(gr); // Passes our off-screen buffer to our paint method, which, // unsuspecting, paints on it g.drawImage(offScreenBuffer, 0, 0, this); // And now we transfer the info in the buffer onto the // graphics context } }