if (buffer == null) buffer = rm.getOffscreenBuffer(this, root.getWidth(), root.getHeight());
  private void paintDoubleBuffered(Rectangle r)  {    RepaintManager rm = RepaintManager.currentManager(this);    // Paint on the offscreen buffer.    Component root = getRoot(this);    Image buffer = rm.getOffscreenBuffer(this, root.getWidth(),                                         root.getHeight());    //Rectangle targetClip = SwingUtilities.convertRectangle(this, r, root);    Point translation = SwingUtilities.convertPoint(this, 0, 0, root);        Graphics g2 = buffer.getGraphics();    g2.translate(translation.x, translation.y);        g2.setClip(r.x, r.y, r.width, r.height);    g2 = getComponentGraphics(g2);        isPaintingDoubleBuffered = true;    try      {        paint(g2);      }    finally      {        isPaintingDoubleBuffered = false;        g2.dispose();      }        // Paint the buffer contents on screen.    rm.commitBuffer(root, new Rectangle(translation.x + r.x,                                        translation.y + r.y, r.width,                                        r.height));      }