if (portBounds.width >= viewPref.width)
if (portBounds.width >= viewMinimum.width)
  public void layoutContainer(Container parent)   {    // The way to interpret this function is basically to ignore the names    // of methods it calls, and focus on the variable names here. getViewRect    // doesn't, for example, return the view; it returns the port bounds in    // view space. Likwise setViewPosition doesn't reposition the view; it     // positions the port, in view coordinates.    JViewport port = (JViewport) parent;        Component view = port.getView();        if (view == null)      return;    // These dimensions and positions are in *view space*.  Do not mix    // variables in here from port space (eg. parent.getBounds()). This    // function should be entirely in view space, because the methods on    // the viewport require inputs in view space.    Rectangle portBounds = port.getViewRect();    Dimension viewPref = view.getPreferredSize();    Dimension viewMinimum = view.getMinimumSize();    Point portLowerRight = new Point(portBounds.x + portBounds.width,                                     portBounds.y + portBounds.height);            // vertical implementation of the above rules    if (portBounds.height >= viewPref.height)      {        portBounds.y = 0;        if ( !(view instanceof Scrollable) || ((Scrollable)view).getScrollableTracksViewportHeight())          viewPref.height = portBounds.height;      }    else      {        int overextension = portLowerRight.y - viewPref.height;        if (overextension > 0)            portBounds.y -= overextension;      }    // horizontal implementation of the above rules    if (portBounds.width >= viewPref.width)      {        portBounds.x = 0;        if ( !(view instanceof Scrollable) || ((Scrollable)view).getScrollableTracksViewportWidth())          viewPref.width = portBounds.width;      }    else      {        int overextension = portLowerRight.x - viewPref.width;        if (overextension > 0)            portBounds.x -= overextension;      }    port.setViewPosition(portBounds.getLocation());    port.setViewSize(viewPref);  }