The flow layout manager is the simplest of all the layout managers. It positions the components in the order they are added to the container. It places the components from left to right, that is, horizontally. Once a row gets completely filled with components then the remaining components are placed in the next row. It is the default layout manager for Applet and Panel. Each component is evenly separated from its neighboring components by leaving a small space not only from above and below it, but also from left and right.
The flow layout manager can be created by using any of the following constructors.
FlowLayout (int alignment)
FlowLayout (int alignment, int hor, int ver)
alignment specifies the alignment of laid out components. It can take one of these constants-FlowLayout.LEFT, FlowLayout.RIGHT, and FlowLayout.CENTER
hor and ver specify the horizontal and vertical space left between each component, respectively
public class WithoutExplicitContentPane extends JFrame
private final int SIZE = 100;
private JButton BtnClckIt = new JButton("Click It");
super("ContentPane with FlowLayout in Java Swing Example");
public static void main(String args)
WithoutExplicitContentPane frame =new WithoutExplicitContentPane();