The border layout manager places components in up to five areas: center, north, south, east and west. Each area can contain only one component.
|(absolute positioning)||(left-to-right relative positioning)||(right-to-left relative positioning)|
The components are laid out according to their preferred sizes. The north and south components may be stretched horizontally. The east and west components may be stretched vertically. The center component may be stretched horizontally and vertically to fill any space left over.
In addition to absolute positioning, BorderLayout supports relative positioning, which swaps west and east components if the component orientation of the container is set to right-to-left. To use relative positioning, first add a component to one of the four side areas and then change the layout constraints property of that component to PAGE_START, PAGE_END, LINE_START or LINE_END.
BorderLayout is part of the standard Java distribution. The API documentation is available here.
Layout manager properties¶
A container with this layout manager has following layout manager properties:
|horizontal gap||The horizontal gap between components.||0|
|vertical gap||The vertical gap between components.||0|
Layout constraints properties¶
A component contained in a container with this layout manager has following layout constraints properties:
|constraints||Specifies where the component will be placed. Possible values: CENTER, NORTH, SOUTH, EAST, WEST, PAGE_START, PAGE_END, LINE_START and LINE_END.|