A flow layout arranges components in a left-to-right flow, much
like lines of text in a paragraph. Flow layouts are typically used
to arrange buttons in a panel. It will arrange
buttons left to right until no more buttons fit on the same line.
Each line is centered.
For example, the following picture shows an applet using the flow
layout manager (its default layout manager) to position three buttons:
Here is the code for this applet:
import java.awt.*;
import java.applet.Applet;
public class myButtons extends Applet {
Button button1, button2, button3;
public void init() {
button1 = new Button("Ok");
button2 = new Button("Open");
button3 = new Button("Close");
add(button1);
add(button2);
add(button3);
}
}
A flow layout lets each component assume its natural (preferred) size.
Returns a string representation of this FlowLayout
object and its values.
LEFT
public static final int LEFT
This value indicates that each row of components
should be left-justified.
CENTER
public static final int CENTER
This value indicates that each row of components
should be centered.
RIGHT
public static final int RIGHT
This value indicates that each row of components
should be right-justified.
FlowLayout
public FlowLayout()
Constructs a new Flow Layout with a centered alignment and a
default 5-unit horizontal and vertical gap.
FlowLayout
public FlowLayout(int align)
Constructs a new Flow Layout with the specified alignment and a
default 5-unit horizontal and vertical gap.
The value of the alignment argument must be one of
FlowLayout.LEFT, FlowLayout.RIGHT,
or FlowLayout.CENTER.
Parameters:
align - the alignment value
FlowLayout
public FlowLayout(int align,
int hgap,
int vgap)
Creates a new flow layout manager with the indicated alignment
and the indicated horizontal and vertical gaps.
The value of the alignment argument must be one of
FlowLayout.LEFT, FlowLayout.RIGHT,
or FlowLayout.CENTER.
Lays out the container. This method lets each component take
its preferred size by reshaping the components in the
target container in order to satisfy the constraints of
this FlowLayout object.