Border vpBorder = sc.getViewportBorder(); if (vpBorder != null) { i = vpBorder.getBorderInsets(sc); width += i.left + i.right; height += i.top + i.bottom; }
  public Dimension minimumLayoutSize(Container parent)  {    // Sun's implementation simply throws a ClassCastException if    // parent is no JScrollPane, so do we.        JScrollPane sc = (JScrollPane) parent;    Insets i = sc.getInsets();    Dimension viewportMinSize = sc.getViewport().getMinimumSize();    int width = i.left + i.right + viewportMinSize.width;    if (sc.getVerticalScrollBarPolicy()        != JScrollPane.VERTICAL_SCROLLBAR_NEVER)      width += sc.getVerticalScrollBar().getMinimumSize().width;    int height = i.top + i.bottom + viewportMinSize.height;    if (sc.getHorizontalScrollBarPolicy()        != JScrollPane.HORIZONTAL_SCROLLBAR_NEVER)      height += sc.getHorizontalScrollBar().getMinimumSize().height;    return new Dimension(width, height);      }