Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.awt

Class BorderLayout

java.lang.Object
|
+--java.awt.BorderLayout

All Implemented Interfaces:

LayoutManager2, Serializable


public class BorderLayout

extends Object

implements LayoutManager2, Serializable

This class implements a layout manager that positions components in certain sectors of the parent container.

Authors:

Field Summary

static java.lang.StringAFTER_LAST_LINE

The constant indicating the position after the last line of the layout.
static java.lang.StringAFTER_LINE_ENDS

The constant indicating the position after the last item of the layout.
static java.lang.StringBEFORE_FIRST_LINE

The constant indicating the position before the first line of the layout.
static java.lang.StringBEFORE_LINE_BEGINS

The constant indicating the position before the first item of the layout.
static java.lang.StringCENTER

Constant indicating the center of the container
static java.lang.StringEAST

Constant indicating the right side of the container
static java.lang.StringLINE_END

The constant indicating the position after the last item of the layout.
static java.lang.StringLINE_START

The constant indicating the position before the first item of the layout.
static java.lang.StringNORTH

Constant indicating the top of the container
static java.lang.StringPAGE_END

The constant indicating the position after the last line of the layout.
static java.lang.StringPAGE_START

The constant indicating the position before the first line of the layout.
static java.lang.StringSOUTH

Constant indicating the bottom of the container
static java.lang.StringWEST

Constant indicating the left side of the container

Constructor Summary

BorderLayout()

Initializes a new instance of BorderLayout with no horiztonal or vertical gaps between components.
BorderLayout(int hgap, int vgap)

Initializes a new instance of BorderLayout with the specified horiztonal and vertical gaps between components.

Method Summary

voidaddLayoutComponent(java.awt.Component component, java.lang.Object constraints)

Adds a component to the layout in the specified constraint position, which must be one of the string constants defined in this class.
voidaddLayoutComponent(java.lang.String constraints, java.awt.Component component)

Adds a component to the layout in the specified constraint position, which must be one of the string constants defined in this class.
intgetHgap()

Returns the horitzontal gap value.
floatgetLayoutAlignmentX(java.awt.Container parent)

Returns the X axis alignment, which is a float indicating where along the X axis this container wishs to position its layout.
floatgetLayoutAlignmentY(java.awt.Container parent)

Returns the Y axis alignment, which is a float indicating where along the Y axis this container wishs to position its layout.
intgetVgap()

Returns the vertical gap value.
voidinvalidateLayout(java.awt.Container parent)

Instructs this object to discard any layout information it might have cached.
voidlayoutContainer(java.awt.Container target)

Lays out the specified container according to the constraints in this object.
java.awt.DimensionmaximumLayoutSize(java.awt.Container target)

Returns the maximum size of the specified container using this layout.
java.awt.DimensionminimumLayoutSize(java.awt.Container target)

Returns the minimum size of the specified container using this layout.
java.awt.DimensionpreferredLayoutSize(java.awt.Container target)

Returns the preferred size of the specified container using this layout.
voidremoveLayoutComponent(java.awt.Component component)

Removes the specified component from the layout.
voidsetHgap(int hgap)

Sets the horizontal gap to the specified value.
voidsetVgap(int vgap)

Sets the vertical gap to the specified value.
java.lang.StringtoString()

Returns a string representation of this layout manager.

Field Details

AFTER_LAST_LINE

public static final String AFTER_LAST_LINE

The constant indicating the position after the last line of the layout. The exact position depends on the writing system: For a top-to-bottom orientation, it is the same as #SOUTH, for a bottom-to-top orientation, it is the same as #NORTH.

This constant is an older name for #PAGE_END which has exactly the same value.

Since:

AFTER_LINE_ENDS

public static final String AFTER_LINE_ENDS

The constant indicating the position after the last item of the layout. The exact position depends on the writing system: For a left-to-right orientation, it is the same as #EAST, for a right-to-left orientation, it is the same as #WEST.

This constant is an older name for #LINE_END which has exactly the same value.

Since:

BEFORE_FIRST_LINE

public static final String BEFORE_FIRST_LINE

The constant indicating the position before the first line of the layout. The exact position depends on the writing system: For a top-to-bottom orientation, it is the same as #NORTH, for a bottom-to-top orientation, it is the same as #SOUTH.

This constant is an older name for #PAGE_START which has exactly the same value.

Since:

BEFORE_LINE_BEGINS

public static final String BEFORE_LINE_BEGINS

The constant indicating the position before the first item of the layout. The exact position depends on the writing system: For a left-to-right orientation, it is the same as #WEST, for a right-to-left orientation, it is the same as #EAST.

This constant is an older name for #LINE_START which has exactly the same value.

Since:

CENTER

public static final String CENTER

Constant indicating the center of the container


EAST

public static final String EAST

Constant indicating the right side of the container


LINE_END

public static final String LINE_END

The constant indicating the position after the last item of the layout. The exact position depends on the writing system: For a left-to-right orientation, it is the same as #EAST, for a right-to-left orientation, it is the same as #WEST.

Since:

LINE_START

public static final String LINE_START

The constant indicating the position before the first item of the layout. The exact position depends on the writing system: For a left-to-right orientation, it is the same as #WEST, for a right-to-left orientation, it is the same as #EAST.

Since:

NORTH

public static final String NORTH

Constant indicating the top of the container


PAGE_END

public static final String PAGE_END

The constant indicating the position after the last line of the layout. The exact position depends on the writing system: For a top-to-bottom orientation, it is the same as #SOUTH, for a bottom-to-top orientation, it is the same as #NORTH.

Since:

PAGE_START

public static final String PAGE_START

The constant indicating the position before the first line of the layout. The exact position depends on the writing system: For a top-to-bottom orientation, it is the same as #NORTH, for a bottom-to-top orientation, it is the same as #SOUTH.

Since:

SOUTH

public static final String SOUTH

Constant indicating the bottom of the container


WEST

public static final String WEST

Constant indicating the left side of the container


Constructor Details

BorderLayout

public BorderLayout()

Initializes a new instance of BorderLayout with no horiztonal or vertical gaps between components.


BorderLayout

public BorderLayout(int hgap, int vgap)

Initializes a new instance of BorderLayout with the specified horiztonal and vertical gaps between components.

Parameters:


Method Details

addLayoutComponent

public void addLayoutComponent(java.awt.Component component, java.lang.Object constraints)

Adds a component to the layout in the specified constraint position, which must be one of the string constants defined in this class.

Parameters:

Throws:


addLayoutComponent

public void addLayoutComponent(java.lang.String constraints, java.awt.Component component)

Adds a component to the layout in the specified constraint position, which must be one of the string constants defined in this class.

Parameters:

Throws:


getHgap

public int getHgap()

Returns the horitzontal gap value.

Returns:


getLayoutAlignmentX

public float getLayoutAlignmentX(java.awt.Container parent)

Returns the X axis alignment, which is a float indicating where along the X axis this container wishs to position its layout. 0 indicates align to the left, 1 indicates align to the right, and 0.5 indicates align to the center.

Parameters:

Returns:


getLayoutAlignmentY

public float getLayoutAlignmentY(java.awt.Container parent)

Returns the Y axis alignment, which is a float indicating where along the Y axis this container wishs to position its layout. 0 indicates align to the top, 1 indicates align to the bottom, and 0.5 indicates align to the center.

Parameters:

Returns:


getVgap

public int getVgap()

Returns the vertical gap value.

Returns:


invalidateLayout

public void invalidateLayout(java.awt.Container parent)

Instructs this object to discard any layout information it might have cached.

Parameters:


layoutContainer

public void layoutContainer(java.awt.Container target)

Lays out the specified container according to the constraints in this object.

Parameters:


maximumLayoutSize

public Dimension maximumLayoutSize(java.awt.Container target)

Returns the maximum size of the specified container using this layout.

Parameters:

Returns:


minimumLayoutSize

public Dimension minimumLayoutSize(java.awt.Container target)

Returns the minimum size of the specified container using this layout.

Parameters:

Returns:


preferredLayoutSize

public Dimension preferredLayoutSize(java.awt.Container target)

Returns the preferred size of the specified container using this layout.

Parameters:

Returns:


removeLayoutComponent

public void removeLayoutComponent(java.awt.Component component)

Removes the specified component from the layout.

Parameters:


setHgap

public void setHgap(int hgap)

Sets the horizontal gap to the specified value.

Parameters:


setVgap

public void setVgap(int vgap)

Sets the vertical gap to the specified value.

Parameters:


toString

public String toString()

Returns a string representation of this layout manager.

Returns: