(horizontalScrollBar != null)
(hsb != null)
  public void layoutContainer(Container parent) {    if (parent instanceof JScrollPane)      {        JScrollPane sc = (JScrollPane) parent;        synchronized (sc.getTreeLock ())          {            Rectangle scrollPaneBounds = sc.getBounds();            JViewport viewport = sc.getViewport();            Dimension viewportSize = viewport.getSize();            Dimension viewSize = viewport.getView().getSize();             int x1 = 0, x2 = 0, x3 = 0, x4 = 0;            int y1 = 0, y2 = 0, y3 = 0, y4 = 0;            x1 = scrollPaneBounds.x;            y1 = scrollPaneBounds.y;            x4 = scrollPaneBounds.x + scrollPaneBounds.width;            y4 = scrollPaneBounds.y + scrollPaneBounds.height;                        if (columnHeader != null)              y2 = columnHeader.getPreferredSize().height;            else              y2 = y1;            if (rowHeader != null)              x2 = rowHeader.getPreferredSize().width;            else              x2 = x1;            int vsbPolicy = sc.getVerticalScrollBarPolicy();            int hsbPolicy = sc.getHorizontalScrollBarPolicy();            boolean showVsb =               (verticalScrollBar != null)              && ((vsbPolicy == VERTICAL_SCROLLBAR_ALWAYS)                  || (vsbPolicy == VERTICAL_SCROLLBAR_AS_NEEDED                       && viewSize.height > viewportSize.height));            boolean showHsb =               (horizontalScrollBar != null)              && ((hsbPolicy == HORIZONTAL_SCROLLBAR_ALWAYS)                  || (hsbPolicy == HORIZONTAL_SCROLLBAR_AS_NEEDED                       && viewSize.width > viewportSize.width));                        if (showVsb)              x3 = x4 - verticalScrollBar.getPreferredSize().width;            else              x3 = x4;            if (showHsb)              y3 = y4 - horizontalScrollBar.getPreferredSize().height;            else              y3 = y4;            // now set the layout            if (viewport != null)              viewport.setBounds(new Rectangle(x2, y2, x3-x2, y3-y2));            if (columnHeader != null)              columnHeader.setBounds(new Rectangle(x2, y1, x3-x2, y2-y1));            if (rowHeader != null)              rowHeader.setBounds(new Rectangle(x1, y2, x2-x1, y3-y2));            if (showVsb)              verticalScrollBar.setBounds(new Rectangle(x3, y2, x4-x3, y3-y2));            if (showHsb)              horizontalScrollBar.setBounds(new Rectangle(x2, y3, x3-x2, y4-y3));            if (upperLeft != null)              upperLeft.setBounds(new Rectangle(x1, y1, x2-x1, y2-y1));            if (upperRight != null)              upperRight.setBounds(new Rectangle(x3, y1, x4-x3, y2-y1));            if (lowerLeft != null)              lowerLeft.setBounds(new Rectangle(x1, y3, x2-x1, y4-y3));            if (lowerRight != null)              lowerRight.setBounds(new Rectangle(x3, y3, x4-x3, y4-y3));          }      }  }