8.8.3 Using Border Layout

Border Layout is the default layout manager for every content pane. The content pane is the main container in all frames, applets, and dialogs.

 

 

The components are laid out according to their preferred sizes and the constraints of the container's size. The NORTH and SOUTH components are stretched horizontally; the EAST and WEST components are stretched vertically; the CENTER components fill the rest of space.

 

Using Bean Builder, the components can be placed in one of the required area by visually dragging/moving and placing them on the particular area (Use the Status Bar, which indicates the mouse position). Alternately the components can be arranged using the Layout Properties , with the container Layout set as Border Layout. Also using the Layout Properties Dialog, the HGap and VGap can be specified.

 

How to use it

 

 

 Note: When adding a component to a container that uses Border Layout, make sure that the status bar shows the status as for example: Jpanel1 Location:West. Do not rely on the component being added to the center by default. If you find that a component is missing from a container controlled by a Border Layout, make sure that you have specified the component's location and that you didn't put another component in the same location.

 

 

Resizing in Border Layout

 

The CENTER component cannot be resized. The NORTH and SOUTH component's size can be increased in the vertical direction. The EAST and WEST component's size can be increased in the horizontal direction.

 

The CENTER component fills up rest of the space.

 

BorderLayout properties

 

The layoutProperties for BorderLayout allows us to set the HGap, VGap and component position.

 

 

 

Aligning Beans in BorderLayout

 

The beans in this layout are aligned to the borders (East, West, North and South directions) automatically. Therefore none of the alignment, spacing or sizing properties are applicable for this type of a layout. When you right click on a multiple selected beans, none of the options are enabled.



Copyright © 2011 ZOHO Corp. All Rights Reserved.