Home » Java FlowLayout

Java FlowLayout

The Java FlowLayout class is used to arrange the components in a line, one after another (in a flow). It is the default layout of the applet or panel.

Fields of FlowLayout class

  1. public static final int LEFT
  2. public static final int RIGHT
  3. public static final int CENTER
  4. public static final int LEADING
  5. public static final int TRAILING

Constructors of FlowLayout class

  1. FlowLayout(): creates a flow layout with centered alignment and a default 5 unit horizontal and vertical gap.
  2. FlowLayout(int align): creates a flow layout with the given alignment and a default 5 unit horizontal and vertical gap.
  3. FlowLayout(int align, int hgap, int vgap): creates a flow layout with the given alignment and the given horizontal and vertical gap.

Example of FlowLayout class: Using FlowLayout() constructor

FileName: FlowLayoutExample.java

Output:

Java FlowLayout

Example of FlowLayout class: Using FlowLayout(int align) constructor

FileName: MyFlowLayout.java

Output:

Java FlowLayout

Example of FlowLayout class: Using FlowLayout(int align, int hgap, int vgap) constructor

FileName: FlowLayoutExample1.java

Output:

Java FlowLayout


Next TopicBoxLayout

You may also like