if (c.getBackground() != null) {  java.awt.Color save = g2.getColor(); g2.setColor(c.getBackground()); g2.fillRect (0, 0, backingStoreWidth, backingStoreHeight); g2.setColor(save);   save = g.getColor(); g.setColor(c.getBackground()); g.fillRect (0, 0, portBounds.width, portBounds.height); g.setColor(save);  } else {  g2.clearRect(0, 0, backingStoreWidth, backingStoreHeight);   g.clearRect(0, 0, portBounds.width, portBounds.height); }
  public void paint(Graphics g, JComponent c)  {          JViewport v = (JViewport)c;    Component view = v.getView();    if (view == null)      return;    Point pos = v.getViewPosition();    Rectangle viewBounds = view.getBounds();    if (backingStoreImage == null         || backingStoreWidth != viewBounds.width        || backingStoreHeight != viewBounds.height)      {        backingStoreImage = v.createImage(viewBounds.width, viewBounds.height);        backingStoreWidth = viewBounds.width;        backingStoreHeight = viewBounds.height;      }    Graphics g2 = backingStoreImage.getGraphics();    view.paint(g2);    g2 = null;    g.drawImage(backingStoreImage,                 -pos.x, -pos.y,                 (ImageObserver)null);  }