gpt4 book ai didi

java - MigLayout - 使单元格随着窗口的增长而增长

转载 作者:行者123 更新时间:2023-12-01 10:33:47 28 4
gpt4 key购买 nike

UI

我想要发生的是东部和南部的 jetty 移动到窗口的边缘,中间的两个单元填充所有其他空间。相反, jetty 是静态的,拉伸(stretch)窗口只会产生空白空间。

    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");

最佳答案

我通过将两个 Pane 添加到 SplitScrollPane 中,然后将其添加到具有“推送、增长”约束的 mainPanel 来解决了这个问题。

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

add(splitPane, "push, grow");

关于java - MigLayout - 使单元格随着窗口的增长而增长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34925277/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com