This applet demonstrates three possible layouts of a set of components.
The left one uses VFlowLayout, which is like a FlowLayout but is used to arrange
components vertically.
VFlowLayout is not standard, but I didn't write it either.
VFlowLayout stacks components, placing each in its preferred vertical space.
The centre one uses VFillLayout, which I did write.
VFillLayout detects components which are TextAreas, Canvases or Panels, and
expands them to fill the available space.
You'll notice that the checkbox in the middle panel is lower than in the left panel,
because VFillLayout has expanded the TextArea and the ImageCanvas to fill the
column completely.
In the green column, VFillLayout has been told not to expand the wizard, but
rather to leave him in his natural size.
This means the TextArea is the only component which can expand, and occupies
more than its natural size.
One trick you can play with VFillLayout is to put an empty Canvas in the middle
of the column.
This canvas will then expand to fill available space, forcing remaining components
to the bottom of the column.
This wouldn't work with a VFlowLayout, because an empty canvas's natural height is 0 -
the Canvas would disappear altogether.
You can tell VFillLayout not to expand a component using the addException() method.
VFillLayout also contains options dictating the horizontal behaviour of the components -
whether they are left-aligned, right-aligned, centred, or fill the column.
VFillLayout lays out invisible components, so if you have an invisible
component in the middle of a VFillLayout, there will be a gap.
I don't know if that's what's supposed to happen.
The horizontal fill layout manager, HFillLayout, works similarly to make
a row of items fill a horizontal space.
In this example, the top row is FlowLayout from the AWT.
Even though there is space on the right, it does not expand the TextField.
The HFillLayout in the centre row includes a TextField and an ImageCanvas, both
of which it expands to fill the available space.
Thus HFillLayout could be used to make a column of Label TextField pairs, where
the labels are aligned on the left and the TextFields take the remaining space.
Try doing that with GridLayout or FlowLayout!
In the bottom row, I have again instructed the layout not to expand the image,
making the TextField wider.
HFillLayout automatically expands TextAreas, TextFields, Canvases and Panels.
You can instruct the layout not to expand a particular component using the addException()
method.
There are options controlling the vertical alignment of components - they can
be top-aligned, bottom-aligned, centred or vertically filled.
HFillLayout leaves a blank space for invisible components.