GridBagLayout has the ability to do what you need, but there are far easier Layout Managers available to do your task.
I recommend using
GridLayout for this task, as it is very easy and useful.
The ways you could do this are:
- Use a JFrame's default LayoutManager (BorderLayout) to add one JPanel to BorderLayout.WEST and add another JPanel to BorderLayout.EAST where each JPanel uses a GridLayout of 3x1 (Row x Column).
- Another way would be to change the JFrame's LayoutManager to GridLayout of 1x2 and then add two JPanels like the above.
- Or change the JFrame's LayoutManger to 3x2 and add all components to the JFrame.
Which ever approach you take (from my suggestion), you will be using GridLayout, so follow the link I provided for a guide.
Heres an example of what I mean.
public JPanel jButtonPanel(){
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new GridLayout(3,1));
buttonPanel.add(myButton);
buttonPanel.add(myButton2);
buttonPanel.add(myButton3);
return buttonPanel;
}
You would then add jButtonPanel() to your JFrame, and do the same for jTextFieldPanel().
Hope this helps.