简体   繁体   English

JSplitPane只向一个方向移动

[英]JSplitPane only moving one direction

I have a nested JSplitPane and the bottom split pane will only move to the left. 我有一个嵌套的JSplitPane,底部的分割窗格只会向左移动。 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. 垂直拆分窗格没有问题,可以上下移动而没有任何问题。

The splitpane's flexibility will be limited by the minimum size of the components it contains. splitpane的灵活性将受其所包含组件的最小尺寸的限制。

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 来自http://docs.oracle.com/javase/tutorial/uiswing/components/splitpane.html#divider

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM