【发布时间】:2016-12-29 20:23:58
【问题描述】:
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
JPanel topPanel = new JPanel(new FlowLayout());
.....
JPanel centrePanel = new JPanel(new FlowLayout(10, 0));
........
JScrollPane scrollPane = new JScrollPane(table);
scrollPane.setPreferredSize(new Dimension(100, 160));
centrePanel.add(glListScrollPane);
........
........
JPanel bottomPanel = new JPanel();
bottomPanel.setLayout(new GridLayout(0, 2));
......
........
panel.add(topPanel, BorderLayout.CENTER);
panel.add(centrePanel, BorderLayout.CENTER);
panel.add(bottomPanel, BorderLayout.CENTER);
frame.add(panel);
frame.add(standardButtonPanel);
public void lockScreen(boolean editable) {
standardButtonPanel.button1.setVisible(editable);
......
}
在进行编辑和取消编辑时。面板正在稍微改变它的位置。 我使用了 BoxLayout,因为我想让组件有自己的大小,并且用户也可以调整屏幕大小。 还有其他方法吗?在哪里可以解决布局问题?
【问题讨论】:
标签: java swing layout boxlayout