location = validLocation(location); Container p = jc.getParent(); Component right = jc.getRightComponent(); Dimension rightPrefSize = right == null ? new Dimension(0, 0) : right.getPreferredSize(); Dimension size = jc.getSize();  if (size.width == 0 && size.height == 0) size = jc.getPreferredSize();  if (getOrientation() == 0 && location > size.height) { location = size.height; while (p != null) { p.setSize(p.getWidth(), p.getHeight() + rightPrefSize.height); p = p.getParent(); } } else if (location > size.width) { location = size.width; while (p != null) { p.setSize(p.getWidth() + rightPrefSize.width, p.getHeight()); p = p.getParent(); } }  setLastDragLocation(getDividerLocation(splitPane)); splitPane.setLastDividerLocation(getDividerLocation(splitPane)); int[] tmpSizes = layoutManager.getSizes(); tmpSizes[0] = location - layoutManager.getInitialLocation(splitPane.getInsets()); tmpSizes[1] = layoutManager.getAvailableSize(splitPane.getSize(), splitPane.getInsets()) - tmpSizes[0]; layoutManager.setSizes(tmpSizes);
dividerLocation = validLocation(location);
  public void setDividerLocation(JSplitPane jc, int location)  {    location = validLocation(location);    Container p = jc.getParent();    Component right = jc.getRightComponent();    Dimension rightPrefSize = right == null ? new Dimension(0, 0)                                           : right.getPreferredSize();    Dimension size = jc.getSize();    // check if the size has been set for the splitpane    if (size.width == 0 && size.height == 0)      size = jc.getPreferredSize();        if (getOrientation() == 0 && location > size.height)      {        location = size.height;        while (p != null)          {            p.setSize(p.getWidth(), p.getHeight() + rightPrefSize.height);            p = p.getParent();          }      }    else if (location > size.width)      {        location = size.width;        while (p != null)          {            p.setSize(p.getWidth() + rightPrefSize.width, p.getHeight());            p = p.getParent();          }      }        setLastDragLocation(getDividerLocation(splitPane));    splitPane.setLastDividerLocation(getDividerLocation(splitPane));    int[] tmpSizes = layoutManager.getSizes();    tmpSizes[0] = location                  - layoutManager.getInitialLocation(splitPane.getInsets());    tmpSizes[1] = layoutManager.getAvailableSize(splitPane.getSize(),                                                 splitPane.getInsets())                  - tmpSizes[0];    layoutManager.setSizes(tmpSizes);    splitPane.revalidate();    splitPane.repaint();  }