if (hsb != null && hsb.isVisible())
if (hsb != null && viewSize.width > viewportSize.width)
  public Dimension preferredLayoutSize(Container parent)   {    // Sun's implementation simply throws a ClassCastException if    // parent is no JScrollPane, so do we.        JScrollPane sc = (JScrollPane) parent;        Dimension viewportSize = viewport.getPreferredSize();        int width = viewportSize.width;        int height = viewportSize.height;        if (hsb != null && hsb.isVisible())          height += hsb.getPreferredSize().height;        if (vsb != null && vsb.isVisible())          width += vsb.getPreferredSize().width;        if (rowHead != null && rowHead.isVisible())          width += rowHead.getPreferredSize().width;        if (colHead != null && colHead.isVisible())          height += colHead.getPreferredSize().height;    Insets i = sc.getInsets();    return new Dimension(width + i.left + i.right,                         height + i.left + i.right);      }