Example
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.
Alignment
LEFT- groups the components at the left edge of the container.
CENTER - centers the components in the container.
RIGHT groups the components at the right edge of the container.
The default alignment in a FlowLayout is CENTER.
To change the alignment, select the flowLayout object in the Component Tree, then specify a value in the 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 Component Tree, 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.
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 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 UI Designer.
Alignment
TOP - groups the components at the top of the container.
MIDDLE - centers the components vertically in the container.
BOTTOM - groups the components so the last component is at the bottom of the container.
The default alignment in a VerticalFlowLayout is MIDDLE.
To change the alignment, select the verticalflowLayout object in the Component Tree, 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 Component Tree, 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, or right-click a component and choose Move to First or Move to Last.
Horizontal fill
horizontalFill lets you specify a fill to edge flag which causes all the components to expand to the container's width.
Warning: This causes problems if the main panel has less space than it needs. It 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.
When you create a BoxLayout2 container, you specify whether its major axis is the X axis (which means 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.