You need to display a component in as much space as it can get.
If it is the only component in its container,
might be a good match.
If you use
you will need to put the space-hungry component in the center.
you will need to set the constraints for the component so that
Another possibility is to use
making the space-hungry component
specify very large preferred and maximum sizes.
You need to display a few components in a compact row
at their natural size.
Consider using a
JPanel to group the components
and using either the
is also good for this.
You need to display a few components of the same size
in rows and columns.
GridLayout is perfect for this.
You need to display a few components in a row or column,
possibly with varying amounts of space between them,
custom alignment, or custom component sizes.
is perfect for this.
You need to display aligned columns,
as in a form-like interface
where a column of labels
is used to describe text fields in an adjacent column.
is a natural choice for this.
used by several Tutorial examples
that lets you easily align multiple rows and columns of components.
You have a complex layout with many components.
Consider either using
a very flexible layout manager such as
or grouping the components into one or more
to simplify layout.
If you take the latter approach,
JPanel might use a different layout manager.