BoxLayout2 allows you to arranges a container's components
either vertically or horizontally. By nesting components in containers,
you can achieve complex layouts. The following graphic shows three
panels (P1, P2, P3) arranged vertically. Each panel contains two buttons
arranged vertically.
When you use BoxLayout2 for a component, you specify
whether its major axis is the Y axis (top placement) or X axis (left to
right placement). Components are arranged from left to right (or top to
bottom), in the same order as they were added to the container.
BoxLayout2 attempts to arrange components at their
preferred widths (for left to right layout) or heights (for top to
bottom layout). The components will not wrap if the container is resized.
If all the components are not the same height in a horizontal layout,
BoxLayout2 attempts to make all the components as high as the highest
component. If that's not possible for a particular component, then
BoxLayout2 aligns that component vertically, according to the
component's Y alignment.
If the components are not all the same width in a vertical alignment,
BoxLayout2 attempts to make all components in the column as wide as the
widest component; if that fails, it aligns them horizontally according
to their X alignments.
Copyright © 1997, 2004, Oracle. All rights reserved.