Java 钮扣尺寸不合适

Java 钮扣尺寸不合适,java,button,jpanel,Java,Button,Jpanel,我正在做一个程序,我的三个按钮有问题。 以下是它们的代码: panel.add(clearButton, c); c.gridwidth = 1; c.fill = GridBagConstraints.VERTICAL; c.gridx = 1; c.gridy = 4; c.weighty = 1.0; panel.add(addButton); c.gridwidth = GridBagConstraints.VERTICAL; c.gridx = 2; c.gridy = 4; c.w

我正在做一个程序,我的三个按钮有问题。 以下是它们的代码:

panel.add(clearButton, c);
c.gridwidth = 1;
c.fill = GridBagConstraints.VERTICAL;
c.gridx = 1;
c.gridy = 4;
c.weighty = 1.0;

panel.add(addButton);
c.gridwidth = GridBagConstraints.VERTICAL;
c.gridx = 2;
c.gridy = 4;
c.weightx = 1.00;

panel.add(calcButton);
c.gridwidth = GridBagConstraints.VERTICAL;
c.gridx = 2;
c.gridy = 4;
c.weightx = 1.00;    
由于某些原因,当程序运行时,clearbutton与addButton和calcButton不同

有人能帮我吗?以下是我使用的参考资料:


如果你需要更多信息,请告诉我

什么是
c
?为什么在添加
addButton
calcButton
时不使用一个按钮


另外,您不需要一直将其字段设置为相同的值。

什么是
c
?为什么在添加
addButton
calcButton
时不使用一个按钮?谢谢。看来我没有足够的代表回答我自己的问题。我添加了panel.add(addButton,c);和面板。添加(calcButton,c);而且已经修好了