MigLayout - 使细胞随着 window 的增长而增长

MigLayout - Making cells grow as window grows

我想要发生的是将东部和南部码头移动到 window 的边缘,中间的两个单元填充所有其他单元 space。 相反,码头是静态的,拉伸 window 只会生成空的 space。

    setLayout(new MigLayout(""));
    treeScrollPane = new JScrollPane();
    add(treeScrollPane, "growy, growx");

    displayedTree = tree;
    treeScrollPane.setViewportView(displayedTree);

    JScrollPane scrollPane = new JScrollPane();
    add(scrollPane, "growy");

    parentsTable = new JTable();
    parentsTable.setFillsViewportHeight(true);





    scrollPane.setViewportView(parentsTable);
    parentsTable.setModel(new DefaultTableModel(


        new Object[][] {
        },
        new String[] {
            "Parent"
        }   
    ) 

    {
        public boolean isCellEditable(int row, int column) {
            return false;
        }

    });
        JPanel easternDock = new JPanel(new MigLayout("insets 0", "", "push[]")); 

    JPanel bottomPanel = new JPanel(new MigLayout());
... add a bunch of stuff to bottomPanel...
    easternDock.add(bottomPanel);
    Box southernDock = Box.createHorizontalBox();
... add a bunch of stuff to southernDock ...
... Do menu stuff ...
    this.add(southernDock, "dock south");
    this.add(menuBar, "dock north");
    this.add(easternDock, "dock east");

我通过将两个窗格添加到 SplitScrollPane,然后将其添加到带有 "push, grow" 约束的主面板来解决这个问题。

JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
                treeScrollPane, scrollPane);
        splitPane.setOneTouchExpandable(true);
        splitPane.setDividerLocation(400);
        splitPane.setContinuousLayout(true);

add(splitPane, "push, grow");