Layouts tell Java where to put components in
containers (JPanel, content pane, etc).
Every panel (and other containers) has a default layout,
but it's better to set the layout explicitly for clarity.
Create a new layout object (using one of its
constructors) and use the container's setLayout method to
set the layout. Each layout has its own way to resize components
to fit the layout, and you must become familiar with these.
FlowLayout.
The result is often ugly, but if there are only a few components,
it's quick. FlowLayout is rarely the
correct layout to use in a finished program.
BorderLayout is often a good
layout for simple programs. More complicated layouts can
often be nesting BorderLayouts within other BorderLayouts.
This and FlowLayout are the most important layouts for beginners.
GridLayout.
BoxLayout.
GridBagLayout.
Getting a GridBagLayout to work correctly can be
time-consuming, but it produces excellent results.
SpringLayout was added in Java 1.4, but is difficult for humans.
It is rumored to be intended for authomatic layout programs..CardLayout is good for something like a wizard interface
which shows one of several possible layouts (think about a stack of index cards).
Tabbed panes are something like a card layout with tabs.