FlowLayout
arranges components in rows from left to right,
and then top to bottom using each component's preferredSize
. FlowLayout
lines up as many components as it can in a
row, then moves to a new row. Typically, FlowLayout
is used
to arrange buttons on a panel.
Note: If you want a panel that arranges the components
vertically, rather than horizontally, see
VerticalFlowLayout
.
You can choose how to arrange the components in the rows of a
FlowLayout
container by specifying an alignment justification of
left, right, or center. You can also specify the amount of gap
(horizontal and vertical spacing) between components and rows. Use the
Inspector to change both the alignment
and gap
properties when you're in the Java Visual Editor.
Alignment
LEFT- groups the components at the left edge of the container.
CENTER - centers the components in the container.
The default alignment in a FlowLayout
is CENTER.
To change the alignment, select the FlowLayout
object
in the Structure window, then specify a value in the Property
Inspector for the alignment
property as follows:
0=LEFT
1=CENTER
2=RIGHT
Gap
The default gap between components in a FlowLayout
is 5
pixels.
To change the horizontal or vertical gap, select the FlowLayout
object in the Structure window, then modify the pixel value of the hgap
(horizontal gap) or vgap
(vertical gap) property in the
Inspector.
Order of Components
To change the order of the components in a FlowLayout
container, drag the component to the new location, or right-click a
component and choose Move to First or
Move to Last.
Copyright © 1997, 2004, Oracle. All rights reserved.