这就是我所拥有的:
这就是我想要的:
这是我的一段代码
container.add(conteneur2 , BorderLayout.EAST);
conteneur2.setBackground(Color.ORANGE);
conteneur2.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
JButton Bouton= new JButton("New remote site");
// Bouton 1
gbc.gridx=0;
gbc.gridy=0;
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.gridheight = 1;
gbc.anchor = GridBagConstraints.LINE_START;
conteneur2.add(bouton,gbc);
所以有什么问题?
1 回答
你需要设置锚
NORTH
并且y权重为1意味着所有自由空间都在y方向上分布 .