@Override
    public void resetToPreferredSizes() {
        Insets i = getInsets();
        if (getOrientation() == VERTICAL_SPLIT) {
            int h = getHeight() - i.top - i.bottom - getDividerSize();
            int topH = getTopComponent().getPreferredSize().height;
            int bottomH = getBottomComponent().getPreferredSize().height;
            int extraSpace = h - topH - bottomH;
            // we have more space than necessary; resize to give each at least
            // preferred size
            if (extraSpace >= 0) {
                setDividerLocation(i.top + topH
                                   + ((int) (extraSpace * getResizeWeight() + .5)));
            }
            // TODO implement shrinking excess space to ensure that one has
            // preferred and nothing more
        } else {
            int w = getWidth() - i.left - i.right - getDividerSize();
            int leftH = getLeftComponent().getPreferredSize().width;
            int rightH = getRightComponent().getPreferredSize().width;
            int extraSpace = w - leftH - rightH;
            // we have more space than necessary; resize to give each at least
            // preferred size
            if (extraSpace >= 0) {
                setDividerLocation(i.left + leftH
                                   + ((int) (extraSpace * getResizeWeight() + .5)));
            }
            // TODO implement shrinking excess space to ensure that one has
            // preferred and nothing more
        }
    }
@Override
    public void resetToPreferredSizes() {
        Insets i = getInsets();
        if (getOrientation() == VERTICAL_SPLIT) {
            int h = getHeight() - i.top - i.bottom - getDividerSize();
            int topH = getTopComponent().getPreferredSize().height;
            int bottomH = getBottomComponent().getPreferredSize().height;
            int extraSpace = h - topH - bottomH;
           
           
            if (extraSpace >= 0) {
                setDividerLocation(i.top + topH
                                   + ((int) (extraSpace * getResizeWeight() + .5)));
            }
           
           
        } else {
            int w = getWidth() - i.left - i.right - getDividerSize();
            int leftH = getLeftComponent().getPreferredSize().width;
            int rightH = getRightComponent().getPreferredSize().width;
            int extraSpace = w - leftH - rightH;
           
           
            if (extraSpace >= 0) {
                setDividerLocation(i.left + leftH
                                   + ((int) (extraSpace * getResizeWeight() + .5)));
            }
           
           
        }
    }
@override public void resettopreferredsizes() { insets i = getinsets(); if (getorientation() == vertical_split) { int h = getheight() - i.top - i.bottom - getdividersize(); int toph = gettopcomponent().getpreferredsize().height; int bottomh = getbottomcomponent().getpreferredsize().height; int extraspace = h - toph - bottomh; if (extraspace >= 0) { setdividerlocation(i.top + toph + ((int) (extraspace * getresizeweight() + .5))); } } else { int w = getwidth() - i.left - i.right - getdividersize(); int lefth = getleftcomponent().getpreferredsize().width; int righth = getrightcomponent().getpreferredsize().width; int extraspace = w - lefth - righth; if (extraspace >= 0) { setdividerlocation(i.left + lefth + ((int) (extraspace * getresizeweight() + .5))); } } }