我想要发生的是东部和南部的码头移动到窗户的边缘,中间的两个单元填充所有其他空间。 相反,码头是静态的,拉伸窗口只会产生空的空间。
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");
答案 0 :(得分:1)
我通过将两个窗格添加到SplitScrollPane,然后使用" push,grow"将其添加到mainPanel来解决这个问题。约束
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
treeScrollPane, scrollPane);
splitPane.setOneTouchExpandable(true);
splitPane.setDividerLocation(400);
splitPane.setContinuousLayout(true);
add(splitPane, "push, grow");