FlowLayout
arranges components in rows from left to right and then top to bottom using each component's natural, 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. In the Java AWT, all panels (including applets) use FlowLayout
by default.
Example
VerticalFlowLayout
.
(VerticalFlowLayout
is a feature of JBuilder Professional and Enterprise.)
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 UI designer.
The default alignment in a FlowLayout
is CENTER.
To change the alignment, select the FlowLayout
object displayed below the container it controls in the component tree, then specify a value in the Inspector for the alignment
property.
FlowLayout
is 5 pixels.
To change the horizontal or vertical gap, select the FlowLayout
object in the component tree, then modify the pixel value of the hgap
(horizontal gap) or vgap
(vertical gap) property in the Inspector.
FlowLayout
container, drag the component to the new location,
or right-click a component and choose Move to First or Move to Last.
This is a feature of JBuilder Professional and Enterprise.
VerticalFlowLayout
arranges components in columns from top to bottom, then left to right using each component's natural, 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.
Example
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 if the components should fill the width of the column, or if the last component should fill the remaining height of the container. Use the Inspector to change these properties when you're in the UI designer.
The default alignment in a VerticalFlowLayout
is TOP.
To change the alignment, select the VerticalflowLayout
object displayed below the container it controls in the component tree, then specify a value in the Inspector for the alignment
property.
VerticalFlowLayout
is 5 pixels.
To change the horizontal or vertical gap, select the VerticalFlowLayout
object in the component tree, then modify the pixel value of the hgap
(horizontal gap) or vgap
(vertical gap) property in the Inspector.
horizontalFill
lets you specify a Fill To Edge flag which causes all the components to expand to the container's width.
The default value for horizontalFill
is True
.
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
.
VerticalFlowLayout
container, drag the component to the new location,
or right-click a component and choose Move to First or Move to Last.
This is a feature of JBuilder Professional and Enterprise.
BoxLayout2
is Swing's BoxLayout
wrapped as a Bean so it can be selected as a layout in the Inspector. It combines both FlowLayout
and VerticalFlowLayout
functionality into one layout manager.
When you create a BoxLayout2
container, you specify whether its major axis is the x-axis (left to right placement) or y-axis (top to bottom placement). Components are arranged from left to right (or top to bottom) in the same order as they were added to the container.
For more information, see the Swing documentation for BoxLayout
and Box
.