I am trying to place two JButtons next to each other in the center of a JFrame, that won\'t re-size the buttons when the JFrame is re-size
Set GridBagLayout to panel1.
panel1.setLayout(new GridBagLayout());
EDIT:
@trashgod : I have to figure out how the default constraints do it.
Because of the field GridBagLayout.defaultConstraints :
This field holds a gridbag constraints instance containing the default values, so if a component does not have gridbag constraints associated with it, then the component will be assigned a copy of the defaultConstraints.
In normal practice, one must have to create GridBagConstraints object and set fields to specify the constraints on each object.
To quote the tutorial:
The preferred approach to set constraints on a component is to use the Container.add variant, passing it a GridBagConstraints object