FlowLayout

FlowLayout is the default LayoutManager for a Panel. A FlowLayout adds components to the container in rows, working from left to right. When it can't fit any more components in a row, it starts a new row--not unlike a word processor with word wrap enabled. When the container gets resized, the components within it get repositioned based on the container's new size. If sufficient space is available, components within FlowLayout containers are given their preferred size. If there is insufficient space, you do not see the components in their entirety.

FlowLayout Methods

Constants

FlowLayout defines three constants, all of which are used to specify alignment. The alignment tells FlowLayout where to start positioning the components on each row. Each component is still added from left to right, no matter what the alignment setting is.

Constructors

Figure 7.1: FlowLayout with six buttons and three different screen sizes

[Graphic: Figure 7-1]

Figure 7.2: FlowLayout with three different alignments

[Graphic: Figure 7-2]

Figure 7.3: FlowLayout with hgap of 0 and vgap of 20

[Graphic: Figure 7-3]Informational methods

LayoutManager methods Miscellaneous methods
java.awt.FlowLayout[hgap=5,vgap=5,align=center]