The FlowLayout is one the most popular and simplest layout manager. It places components in a container from left to right in the order in which they were added to the container. When one row is filled, layout advances to the next row. It is analogous to lines of text in a paragraph. Components managed by a FlowLayout are always set to their preferred size (both width and height) regardless of the size of the parent container. Whenever the container is resized then the components in the container are also adjusted from the top-left comer. The FlowLayout is the default layout manager for a Panel, Applet and JPanel.
The java.awt.FlowLayout class contain the following constructors and methods:
Creates a default FlowLayout manager: centered alignment, horizontal spacing and 5 vertical units.
Creates a FlowLayout manager with alignment and given horizontal and vertical spacing of 5 units.
FlowLayout (int, int, int)
Creates a FlowLayout manager with alignment, horizontal and vertical spacing data.
Gets the alignment of this layout.
Gets the horizontal spacing.
Gets the vertical spacing.
Specifies the alignment of this layout.
Specifies the horizontal spacing.
Specifies the vertical spacing.
Also has the constant–FlowLayout.LEFT, and FlowLayout.CENTER FlowLayout.RIGHT who can be used to specify or determine the alignment of this layout manager.
class FlowLayoutExample extends Frame
Button button =new Button;
button[i]=new Button("Button "+(i+1));
public static void main(String args)
FlowLayoutExample frame = new FlowLayoutExample();
frame.setTitle("FlowLayout in Java Example");