Layout Manager: A layout manager is used in java.awt package to automatically align the controls in the frame window. Every object of Container class has a layout manager. LayoutManager interface is used to encapsulate the layout managers. Whenever a component is added layout manager is informed. Also, when a component is re-sized or changed layout manager is notified.
Method defined by LayoutManager interface:
setLayout( ) method: It is used to set a layout manager.
void setLayout(LayoutManager lob)
where, lob is the layout object. To set positions of the controls manually null is passed as lob.
FlowLayout class: FlowLayout class provides the default layout manager used by java.awt. It places components from upper left corner, left to right and top to bottom. When a component is not fitting on a current line then the next line is used. Spaces on all four sides are left for a component.
Types of constructors defined by FlowLayout class:
Type-1: To create a default layout with 5 pixels of space between components.
Type-2: To set the alignment of line.
Type-3: To set horizontal and vertical space between components.
FlowLayout(int l, int h, int v)
Values of l can be: FlowLayout.CENTER, FlowLayout.LEFT, or FlowLayout.RIGHT.