if (backingStoreImage == null || backingStoreWidth != viewBounds.width || backingStoreHeight != viewBounds.height)
switch (port.getScrollMode())
  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();    Rectangle portBounds = v.getBounds();    if (viewBounds.width == 0         || viewBounds.height == 0        || portBounds.width == 0        || portBounds.height == 0)      return;    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();    if (c.getBackground() != null)      {        // fill the backing store background        java.awt.Color save = g2.getColor();        g2.setColor(c.getBackground());        g2.fillRect (0, 0, backingStoreWidth, backingStoreHeight);        g2.setColor(save);        // fill the viewport background        save = g.getColor();        g.setColor(c.getBackground());        g.fillRect (0, 0, portBounds.width, portBounds.height);        g.setColor(save);      }    else      {        // clear the backing store background        g2.clearRect(0, 0, backingStoreWidth, backingStoreHeight);        // clear the viewport background        g.clearRect(0, 0, portBounds.width, portBounds.height);      }    g2.setClip(g.getClipBounds());    g2.translate(-pos.x, -pos.y);    try       {    view.paint(g2);      }    finally      {        g2.translate(pos.x, pos.y);      }    g2 = null;    g.drawImage(backingStoreImage,                 0, 0,                 (ImageObserver)null);  }