synchronized (sc.getTreeLock ()) { Dimension insetsSize = new Dimension(0,0); Dimension viewportSize = new Dimension(0,0); Dimension viewportInsetsSize = new Dimension(0,0); Dimension columnHeaderSize = new Dimension(0,0); Dimension rowHeaderSize = new Dimension(0,0); Dimension verticalScrollBarSize = new Dimension(0,0); Dimension horizontalScrollBarSize = new Dimension(0,0);  Insets insets = sc.getInsets(); Border viewportBorder = sc.getViewportBorder(); Insets viewportInsets = null;  if (viewportBorder != null) { viewportInsets = viewportBorder.getBorderInsets(parent); if (viewportInsets != null) viewportInsetsSize.setSize(viewportInsets.left + viewportInsets.right, viewportInsets.top + viewportInsets.bottom); }  if (insets != null) insetsSize.setSize(insets.left + insets.right, insets.top + insets.bottom);  maybeSetMinimumSize(colHead, columnHeaderSize); maybeSetMinimumSize(rowHead, rowHeaderSize);  if (vsbPolicy != VERTICAL_SCROLLBAR_NEVER) maybeSetMinimumSize(vsb, verticalScrollBarSize);  if (hsbPolicy != HORIZONTAL_SCROLLBAR_NEVER) maybeSetMinimumSize(hsb, horizontalScrollBarSize);  return new Dimension(insetsSize.width + viewportSize.width + viewportInsetsSize.width + rowHeaderSize.width + verticalScrollBarSize.width, insetsSize.height + viewportSize.height + viewportInsetsSize.height + columnHeaderSize.height + horizontalScrollBarSize.height);
Dimension viewportSize = viewport.getMinimumSize(); int width = viewportSize.width; int height = viewportSize.height; if (hsb != null && hsb.isVisible()) height += hsb.getMinimumSize().height; if (vsb != null && vsb.isVisible()) width += vsb.getMinimumSize().width; if (rowHead != null && rowHead.isVisible()) width += rowHead.getMinimumSize().width; if (colHead != null && colHead.isVisible()) height += colHead.getMinimumSize().height; return new Dimension(width, height);
  public Dimension minimumLayoutSize(Container parent)  {    if (parent instanceof JScrollPane)      {        JScrollPane sc = (JScrollPane) parent;        synchronized (sc.getTreeLock ())          {            Dimension insetsSize = new Dimension(0,0);             Dimension viewportSize = new Dimension(0,0);             Dimension viewportInsetsSize = new Dimension(0,0);             Dimension columnHeaderSize = new Dimension(0,0);             Dimension rowHeaderSize = new Dimension(0,0);             Dimension verticalScrollBarSize = new Dimension(0,0);             Dimension horizontalScrollBarSize = new Dimension(0,0);             Insets insets = sc.getInsets();            Border viewportBorder = sc.getViewportBorder();            Insets viewportInsets = null;            if (viewportBorder != null)              {                viewportInsets = viewportBorder.getBorderInsets(parent);                if (viewportInsets != null)                  viewportInsetsSize.setSize(viewportInsets.left + viewportInsets.right,                                             viewportInsets.top + viewportInsets.bottom);              }                        if (insets != null)              insetsSize.setSize(insets.left + insets.right,                                 insets.top + insets.bottom);            maybeSetMinimumSize(colHead, columnHeaderSize);            maybeSetMinimumSize(rowHead, rowHeaderSize);                        if (vsbPolicy != VERTICAL_SCROLLBAR_NEVER)              maybeSetMinimumSize(vsb, verticalScrollBarSize);            if (hsbPolicy != HORIZONTAL_SCROLLBAR_NEVER)              maybeSetMinimumSize(hsb, horizontalScrollBarSize);                        return new Dimension(insetsSize.width                                  + viewportSize.width                                 + viewportInsetsSize.width                                 + rowHeaderSize.width                                 + verticalScrollBarSize.width,                                 insetsSize.height                                 + viewportSize.height                                 + viewportInsetsSize.height                                 + columnHeaderSize.height                                 + horizontalScrollBarSize.height);          }      }    else      {        return new Dimension(0,0);      }  }