I am working on a program and I am having an issue with three of my buttons.
Here is the code for them:
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;
For some reason when the program runs, the clearbutton is not the same as the addButton and calcButton.
Can anyone help me on this? Here is the reference I am using: http://docs.oracle.com/javase/6/docs/api/java/awt/GridBagLayout.html
Please tell me if you need more info!
What is
c? Why aren’t you using one when you addaddButtonandcalcButton?Also, you don’t need to keep setting its fields to the same values.