The way to layout components in a GUI is:
JPanel is a container
that is used to group components.
Components added to a panel become inseparable.
Graphically a panel corresponds to a rectangular
section of the screen.
Each panel has its own layout manager
that lays out the components inside the panel.
The default layout manager of
flow layout, which is often ideal.
But you may add whichever layout manager is most appropriate.
Now the panels are added to a frame. The content pane's layout manager arranges the panels as if each one were a single component. Panels do not have visible edges.