Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

java.awt
Class BorderLayout  view BorderLayout download BorderLayout.java

java.lang.Object
  extended byjava.awt.BorderLayout
All Implemented Interfaces:
LayoutManager, LayoutManager2, java.io.Serializable

public class BorderLayout
extends java.lang.Object
implements LayoutManager2, java.io.Serializable

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


Field Summary
static java.lang.String AFTER_LAST_LINE
          The constant indicating the position after the last line of the layout.
static java.lang.String AFTER_LINE_ENDS
          The constant indicating the position after the last item of the layout.
static java.lang.String BEFORE_FIRST_LINE
          The constant indicating the position before the first line of the layout.
static java.lang.String BEFORE_LINE_BEGINS
          The constant indicating the position before the first item of the layout.
private  Component center
           
static java.lang.String CENTER
          Constant indicating the center of the container
private  Component east
           
static java.lang.String EAST
          Constant indicating the right side of the container
private  Component firstItem
           
private  Component firstLine
           
private  int hgap
           
private  Component lastItem
           
private  Component lastLine
           
static java.lang.String LINE_END
          The constant indicating the position after the last item of the layout.
static java.lang.String LINE_START
          The constant indicating the position before the first item of the layout.
private static int MAX
           
private static int MIN
           
private  Component north
           
static java.lang.String NORTH
          Constant indicating the top of the container
static java.lang.String PAGE_END
          The constant indicating the position after the last line of the layout.
static java.lang.String PAGE_START
          The constant indicating the position before the first line of the layout.
private static int PREF
           
private static long serialVersionUID
          Serialization constant.
private  Component south
           
static java.lang.String SOUTH
          Constant indicating the bottom of the container
private  int vgap
           
private  Component west
           
static java.lang.String WEST
          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
 void addLayoutComponent(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.
 void addLayoutComponent(java.lang.String constraints, Component component)
          Deprecated. This method is deprecated in favor of addLayoutComponent(Component, Object).
private  Dimension calcCompSize(Component comp, int what)
           
private  Dimension calcSize(Container target, int what)
          This is a helper function used to compute the various sizes for this layout.
 java.lang.Object getConstraints(Component c)
          Return the constraint corresponding to a component in this layout.
 int getHgap()
          Returns the horitzontal gap value.
 float getLayoutAlignmentX(Container parent)
          Returns the X axis alignment, which is a float indicating where along the X axis this container wishs to position its layout.
 float getLayoutAlignmentY(Container parent)
          Returns the Y axis alignment, which is a float indicating where along the Y axis this container wishs to position its layout.
 Component getLayoutComponent(Container container, java.lang.Object constraints)
          Return the component at the specified location, which must be one of the absolute constants such as CENTER or SOUTH.
 Component getLayoutComponent(java.lang.Object constraints)
          Return the component at the indicated location, or null if no component is at that location.
 int getVgap()
          Returns the vertical gap value.
 void invalidateLayout(Container parent)
          Instructs this object to discard any layout information it might have cached.
 void layoutContainer(Container target)
          Lays out the specified container according to the constraints in this object.
 Dimension maximumLayoutSize(Container target)
          Returns the maximum size of the specified container using this layout.
 Dimension minimumLayoutSize(Container target)
          Returns the minimum size of the specified container using this layout.
 Dimension preferredLayoutSize(Container target)
          Returns the preferred size of the specified container using this layout.
 void removeLayoutComponent(Component component)
          Removes the specified component from the layout.
 void setHgap(int hgap)
          Sets the horizontal gap to the specified value.
 void setVgap(int vgap)
          Sets the vertical gap to the specified value.
 java.lang.String toString()
          Returns a string representation of this layout manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NORTH

public static final java.lang.String NORTH
Constant indicating the top of the container

See Also:
Constant Field Values

SOUTH

public static final java.lang.String SOUTH
Constant indicating the bottom of the container

See Also:
Constant Field Values

EAST

public static final java.lang.String EAST
Constant indicating the right side of the container

See Also:
Constant Field Values

WEST

public static final java.lang.String WEST
Constant indicating the left side of the container

See Also:
Constant Field Values

CENTER

public static final java.lang.String CENTER
Constant indicating the center of the container

See Also:
Constant Field Values

BEFORE_FIRST_LINE

public static final java.lang.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 55 , for a bottom-to-top orientation, it is the same as SOUTH 55 .

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

Since:
1.2
See Also:
Constant Field Values

AFTER_LAST_LINE

public static final java.lang.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 55 , for a bottom-to-top orientation, it is the same as NORTH 55 .

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

Since:
1.2
See Also:
Constant Field Values

BEFORE_LINE_BEGINS

public static final java.lang.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 55 , for a right-to-left orientation, it is the same as EAST 55 .

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

Since:
1.2
See Also:
Constant Field Values

AFTER_LINE_ENDS

public static final java.lang.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 55 , for a right-to-left orientation, it is the same as WEST 55 .

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

Since:
1.2
See Also:
Constant Field Values

PAGE_START

public static final java.lang.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 55 , for a bottom-to-top orientation, it is the same as SOUTH 55 .

Since:
1.4
See Also:
Constant Field Values

PAGE_END

public static final java.lang.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 55 , for a bottom-to-top orientation, it is the same as NORTH 55 .

Since:
1.4
See Also:
Constant Field Values

LINE_START

public static final java.lang.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 55 , for a right-to-left orientation, it is the same as EAST 55 .

Since:
1.4
See Also:
Constant Field Values

LINE_END

public static final java.lang.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 55 , for a right-to-left orientation, it is the same as WEST 55 .

Since:
1.4
See Also:
Constant Field Values

serialVersionUID

private static final long serialVersionUID
Serialization constant.

See Also:
Constant Field Values

north

private Component north

south

private Component south

east

private Component east

west

private Component west

center

private Component center

firstLine

private Component firstLine

lastLine

private Component lastLine

firstItem

private Component firstItem

lastItem

private Component lastItem

hgap

private int hgap

vgap

private int vgap

MIN

private static final int MIN
See Also:
Constant Field Values

MAX

private static final int MAX
See Also:
Constant Field Values

PREF

private static final int PREF
See Also:
Constant Field Values
Constructor Detail

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.

Method Detail

getHgap

public int getHgap()
Returns the horitzontal gap value.


setHgap

public void setHgap(int hgap)
Sets the horizontal gap to the specified value.


getVgap

public int getVgap()
Returns the vertical gap value.


setVgap

public void setVgap(int vgap)
Sets the vertical gap to the specified value.


addLayoutComponent

public void addLayoutComponent(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.

Specified by:
addLayoutComponent in interface LayoutManager2

addLayoutComponent

public void addLayoutComponent(java.lang.String constraints,
                               Component component)
Deprecated. This method is deprecated in favor of addLayoutComponent(Component, Object).

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

Specified by:
addLayoutComponent in interface LayoutManager

removeLayoutComponent

public void removeLayoutComponent(Component component)
Removes the specified component from the layout.

Specified by:
removeLayoutComponent in interface LayoutManager

minimumLayoutSize

public Dimension minimumLayoutSize(Container target)
Returns the minimum size of the specified container using this layout.

Specified by:
minimumLayoutSize in interface LayoutManager

preferredLayoutSize

public Dimension preferredLayoutSize(Container target)
Returns the preferred size of the specified container using this layout.

Specified by:
preferredLayoutSize in interface LayoutManager

maximumLayoutSize

public Dimension maximumLayoutSize(Container target)
Returns the maximum size of the specified container using this layout.

Specified by:
maximumLayoutSize in interface LayoutManager2

getLayoutAlignmentX

public float getLayoutAlignmentX(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.

Specified by:
getLayoutAlignmentX in interface LayoutManager2

getLayoutAlignmentY

public float getLayoutAlignmentY(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.

Specified by:
getLayoutAlignmentY in interface LayoutManager2

invalidateLayout

public void invalidateLayout(Container parent)
Instructs this object to discard any layout information it might have cached.

Specified by:
invalidateLayout in interface LayoutManager2

layoutContainer

public void layoutContainer(Container target)
Lays out the specified container according to the constraints in this object.

Specified by:
layoutContainer in interface LayoutManager

toString

public java.lang.String toString()
Returns a string representation of this layout manager.


calcCompSize

private Dimension calcCompSize(Component comp,
                               int what)

calcSize

private Dimension calcSize(Container target,
                           int what)
This is a helper function used to compute the various sizes for this layout.


getLayoutComponent

public Component getLayoutComponent(java.lang.Object constraints)
Return the component at the indicated location, or null if no component is at that location. The constraints argument must be one of the location constants specified by this class.

Since:
1.5

getLayoutComponent

public Component getLayoutComponent(Container container,
                                    java.lang.Object constraints)
Return the component at the specified location, which must be one of the absolute constants such as CENTER or SOUTH. The container's orientation is used to map this location to the correct corresponding component, so for instance in a right-to-left container, a request for the EAST component could return the LINE_END component. This will return null if no component is available at the given location.


getConstraints

public java.lang.Object getConstraints(Component c)
Return the constraint corresponding to a component in this layout. If the component is null, or is not in this layout, returns null. Otherwise, this will return one of the constraint constants defined in this class.

Since:
1.5