The BorderLayout layout manager divides the container into five regions that are named geographically: Top (north), lower (south), left (west), right (east) and central (center). North corresponds to the top of the container. You can add only one component per region to a container controlled by a BorderLayout layout manager. However, this limitation can be overcome by adding a container with multiple components (such as Panel). Components laid out by this layout manager normally do not get to have their preferred size.
The components added to the NORTH or SOUTH regions will get its width equal to the width of the container while maintaining their preferred height. The components added to the EAST or WEST regions will get its height equal to the height of the container minus any components in NORTH or SOUTH while maintaining their preferred width. The component that are added to the CENTER will fill up the rest of the space in horizontal and vertical dimensions. BorderLayout is the default layout manager for a JApplet, JFrame, JDialog and JWindow.
The java.awt.BorderLayout class contain the following constructors and methods that can use to customize this manager:
Creates a new layout manager without spacing between regions.
BorderLayout (int, int)
Creates a new layout manager with the spacing horizontal and vertical specified.
Gets the horizontal spacing.
Gets the vertical spacing.
Specifies the horizontal spacing.
Specifies the vertical spacing.
class BorderLayoutExample extends Frame
public static void main(String args)
BorderLayoutExample frame = new BorderLayoutExample();
frame.setTitle("BorderLayout in Java Example");