this.getContentPanel().add(sortOrderScrollPane, new GridBagConstraints(0, 0, 5, 5, 0.0, 0.0,
GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(5, 5, 10,10), 0, 0));
this.getContentPanel().add(toFirstSortButton, new GridBagConstraints(5, 4, 1, 1, 0.0, 0.0,
GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(0, 5, 5, 10), 0, 0));
toFirstSortButton
占据了整个列。任何人都可以解释原因吗?
答案 0 :(得分:1)
将GridBagConstraints.BOTH
更改为GridBagConstraints.NONE
此外,我建议使用以下示例中的GridBagLayout
。它更容易阅读并防止错误,因为您不再需要搜索正确的参数。
this.getContentPanel().setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.NONE;
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 1;
gbc.weighty = 1;
gbc.gridwidth = 1;
gbc.insets = new Insets(0, 0, 0, 0);
this.getContentPanel().add(sortOrderScrollPane, gbc);
//etc..