public void paint(Graphics g) { if (offScreenGraphics == null) { offScreenImage = createImage(size().width, size().height); offScreenGraphics = offScreenImage.getGraphics(); } offScreenGraphics.setColor(getBackground()); offScreenGraphics.fillRect(0, 0, size().width, size().height); drawCurves(offScreenGraphics); drawMarks(offScreenGraphics); drawStrings(offScreenGraphics); drawInstruction(offScreenGraphics); g.drawImage(offScreenImage, 0, 0, this); }