public class BorderLayout extends java.lang.Object implements LayoutManager2, java.io.Serializable
| Modifier and Type | Field and Description |
|---|---|
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.
|
static java.lang.String |
CENTER
Constant indicating the center of the container
|
static java.lang.String |
EAST
Constant indicating the right side of the container
|
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.
|
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.
|
static java.lang.String |
SOUTH
Constant indicating the bottom of the container
|
static java.lang.String |
WEST
Constant indicating the left side of the container
|
| Constructor and Description |
|---|
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. |
| Modifier and Type | Method and Description |
|---|---|
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). |
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.
0 indicates align to the left, 1 indicates align to the right, and 0.5
indicates align to the center. |
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. |
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.
|
public static final java.lang.String NORTH
public static final java.lang.String SOUTH
public static final java.lang.String EAST
public static final java.lang.String WEST
public static final java.lang.String CENTER
public static final java.lang.String BEFORE_FIRST_LINE
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.
public static final java.lang.String AFTER_LAST_LINE
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.
public static final java.lang.String BEFORE_LINE_BEGINS
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.
public static final java.lang.String AFTER_LINE_ENDS
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.
public static final java.lang.String PAGE_START
NORTH, for
a bottom-to-top orientation, it is the same as SOUTH.public static final java.lang.String PAGE_END
SOUTH, for
a bottom-to-top orientation, it is the same as NORTH.public static final java.lang.String LINE_START
WEST, for
a right-to-left orientation, it is the same as EAST.public static final java.lang.String LINE_END
EAST, for
a right-to-left orientation, it is the same as WEST.public BorderLayout()
BorderLayout with no
horiztonal or vertical gaps between components.public BorderLayout(int hgap, int vgap)
BorderLayout with the
specified horiztonal and vertical gaps between components.hgap - The horizontal gap between components.vgap - The vertical gap between components.public int getHgap()
public void setHgap(int hgap)
hgap - The new horizontal gap.public int getVgap()
public void setVgap(int vgap)
vgap - The new vertical gap value.public void addLayoutComponent(Component component, java.lang.Object constraints)
addLayoutComponent in interface LayoutManager2component - The component to add.constraints - The constraint string.java.lang.IllegalArgumentException - If the constraint object is not
a string, or is not one of the specified constants in this class.public void addLayoutComponent(java.lang.String constraints, Component component)
addLayoutComponent(Component, Object).addLayoutComponent in interface LayoutManagerconstraints - The constraint string.component - The component to add.java.lang.IllegalArgumentException - If the constraint object is not
one of the specified constants in this class.public void removeLayoutComponent(Component component)
removeLayoutComponent in interface LayoutManagercomponent - The component to remove from the layout.public Dimension minimumLayoutSize(Container target)
minimumLayoutSize in interface LayoutManagertarget - The container to calculate the minimum size for.LayoutManager.preferredLayoutSize(Container)public Dimension preferredLayoutSize(Container target)
preferredLayoutSize in interface LayoutManagertarget - The container to calculate the preferred size for.LayoutManager.minimumLayoutSize(Container)public Dimension maximumLayoutSize(Container target)
maximumLayoutSize in interface LayoutManager2target - The container to calculate the maximum size for.Component.getMaximumSize()public float getLayoutAlignmentX(Container parent)
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.getLayoutAlignmentX in interface LayoutManager2parent - The parent container.public float getLayoutAlignmentY(Container parent)
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.getLayoutAlignmentY in interface LayoutManager2parent - The parent container.public void invalidateLayout(Container parent)
invalidateLayout in interface LayoutManager2parent - The parent container.public void layoutContainer(Container target)
layoutContainer in interface LayoutManagertarget - The container to lay out.public java.lang.String toString()
toString in class java.lang.ObjectObject.getClass(),
Object.hashCode(),
Class.getName(),
Integer.toHexString(int)public Component getLayoutComponent(java.lang.Object constraints)
constraints - the locationjava.lang.IllegalArgumentException - if the constraints argument is not
recognizedpublic Component getLayoutComponent(Container container, java.lang.Object constraints)
container - the container whose orientation is usedconstraints - the absolute location of the componentjava.lang.IllegalArgumentException - if the constraint is not recognizedpublic java.lang.Object getConstraints(Component c)
c - the component