Question

I have a nested JSplitPane and the bottom split pane will only move to the left. It won't move to the right of the position even if/after I've moved it to the left.

    dataEntry=new JTabbedPane();
    formformat=new JPanel();
    dataEntry.addTab("Table Entry", tableScroll);
    dataEntry.setMnemonicAt(0, KeyEvent.VK_1);
    dataEntry.addTab("Form Entry", formformat);
    dataEntry.setMnemonicAt(0, KeyEvent.VK_2);

    utils=new JTabbedPane();
    helphtml=new JEditorPane();
    utils.addTab("Field Help", helphtml);
    utils.setMnemonicAt(0, KeyEvent.VK_3);
    microImage=new JLabel();
    utils.addTab("Image Navigation", microImage);
    utils.setMnemonicAt(0, KeyEvent.VK_4);

    //leftright=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
    //        new JPanel().add(dataEntry), new JPanel().add(utils));
    leftright=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    leftright.add(dataEntry);
    leftright.add(utils);
    leftright.setContinuousLayout(true);
    leftright.setOneTouchExpandable(true);
    try {
        System.out.println("divx loc"+sa.getXDivider(username));
        leftright.setDividerLocation(sa.getXDivider(username));
    } catch (Exception e1) {
        leftright.setDividerLocation(750);
    }
    createImage();
    if(!imgurl.equals("NONE"))
        topbot=new JSplitPane(JSplitPane.VERTICAL_SPLIT,imgpnl, leftright);
    else
        topbot=new JSplitPane(JSplitPane.VERTICAL_SPLIT,batchImage, leftright);

    topbot.setOneTouchExpandable(true);
    try {

        System.out.println("divy loc"+sa.getYDivider(username));
        topbot.setDividerLocation(sa.getYDivider(username));
    } catch (Exception e) {
        topbot.setDividerLocation(600);
    }

The commented out constructor doesn't work either, I've tried both and neither method changes anything.

Why does the horizontal splitpane only move in one direction? The vertical split pane has no problems and can move up and down with no problems.

Was it helpful?

Solution

The splitpane's flexibility will be limited by the minimum size of the components it contains.

To make your split pane work well, you often need to set the minimum sizes of components in the split pane, as well as the preferred size of either the split pane or its contained components. Choosing which sizes you should set is an art that requires understanding how a split pane's preferred size and divider location are determined.

from http://docs.oracle.com/javase/tutorial/uiswing/components/splitpane.html#divider

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top