VerticalFlowLayout
arranges components in columns from top
to bottom, then left to right using each component's preferredSize
. VerticalFlowLayout
lines up as many components as it can in a
column, then moves to a new column. Typically, VerticalFlowLayout
is used to arrange buttons on a panel.
You can choose how to arrange the components in the columns of a
VerticalFlowLayout
container by specifying an alignment
justification of top, middle, or bottom. You can also specify the amount
of gap (horizontal and vertical spacing) between components and columns.
It also has properties that let you specify the components should fill
the width of the column, or the last component should fill the remaining
height of the container. Use the Inspector to change these properties
when you're in the Java Visual Editor.
Alignment
The default alignment in a VerticalFlowLayout
is MIDDLE.
To change the alignment, select the verticalFlowLayout object in the Structure window, then specify a value in the Inspector for the alignment property as follows:
0=TOP
1=MIDDLE
2=BOTTOM
Gap
The default gap between components in a VerticalFlowLayout
is 5 pixels.
To change the horizontal or vertical gap, select the
VerticalFlowLayout
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 VerticalFlowLayout
container, drag the component to the new location.
Horizontal Fill
horizontalFill
lets you specify a fill to edge flag which
causes all the components to expand to the container's width.
Warning: Your program can become unstable if the main panel has less space than it needs. This property also prohibits multi-column output.
The default value for horizontalFill
is True
.
Vertical fill
verticalFill
lets you specify a vertical fill flag that
causes the last component to fill the remaining height of the container.
The default value for verticalFill
is False
.
Copyright © 1997, 2004, Oracle. All rights reserved.