BorderLayout, Insets class in java.awt package: constructors, methods

BorderLayout class: It is used to define layout style for top level windows. It has a center, with 4 fixed width components in the corners.

Constructors defined by BorderLayout class:

To create a default border layout.

BorderLayout( )

To set horizontal and vertical space between components.

BorderLayout(int h, int v)

Constants defined by BorderLayout class: BorderLayout.EAST, BorderLayout.WEST, BorderLayout.NORTH, BorderLayout.SOUTH and BorderLayout.CENTER.

Method defined by BorderLayout class:

add( ) method: It is used to add components.


void add(Component cob, Object region);

where, cob is component which will be added.

Insets class: It is used to adjust space between components and frame window.

Constructor defined by Insets class:

To leave spaces in top, left, bottom, and right:

Insets(int top, int left, int bottom, int right)

Method defined by Insets class:

getInsets( ) method: It is used to get the current insets values.

Insets getInsets( )

Leave a Reply