if (null == g) {
if (g == null) {
    public void paintComponent(Graphics g) {        // No Graphics, no painting.        if (null == g) {            return;        }        // create an off-screen image        Image offScr = createImage(getSize().width, getSize().height);        // Get a Graphics object to draw with.        Graphics offG = offScr.getGraphics();        // set clipping to current size.        offG.setClip(0, 0, getSize().width, getSize().height);        // Clear the panel as needed         clearGraphics(offG);        //Draw background        Enumeration iter = bgDrawers.elements();        while (iter.hasMoreElements()) {            BackGroundDrawer bgd = (BackGroundDrawer) iter.nextElement();            bgd.drawInto(offG, getSize().width, getSize().height);        }        // Let the parent panel repaint the components inside.        super.paintComponent(offG);        // draw the off-screen image to the sreen.        g.drawImage(offScr, 0, 0, null);        //crean up the local graphics reference.        offG.dispose();    }