A container must contain a layout manager to perform its work. If a layout manager is not associated with a container, the container will place the components wherever specified using following methods.
A layout manager must be present in a container so that work could be performed. If container and layout manager are not associated with each other, the components will be placed by the container wherever specified by using these methods. setBounds()setSize()setLocation()
Pre-defined entire layout manager is present in java.awt. Interface java.awt.LayoutManager is implemented by the layout manager.
Every AWT i.e Abstract Windows Toolkit & swing container consists of a pre-defined default layout manager. container.setLayout can be used for setting or changing the layout manager.Interface java.awt.LayoutManager is implemented for customized layout manager.
Layout managers that are pre-defined are given here: java.awt.BorderLayoutjava.awt.FlowLayoutjava.awt.CardLayoutjava.awt.GridLayoutjava.awt.GridBagLayout
• FlowLayout: Applet and Panel has FlowLayout as their default layout. It lays components from left to right.
• BorderLayout: Frame and Dialog has BorderLayout as their default layout. It lays components in north, south, east, west and center.
• CardLayout: stack of same size components arranged inside each other.
• GridLayout: Makes a bunch of components equal in size and displays them in the requested number of rows and columns.