public Graphics getOffScreenGraphics() {
        Dimension d = getSize();
        if (offScreen == null || offScreen.getWidth(null) != d.width || offScreen.getHeight(null) != d.height) {
            offScreen = createImage(d.width, d.height);
        }
        return offScreen.getGraphics();
    }