Packageorg.aswing
Classpublic class BorderLayout
InheritanceBorderLayout Inheritance EmptyLayout
SubclassesFrameTitleBarLayout

A border layout lays out a container, arranging and resizing its components to fit in five regions: north, south, east, west, and center. Each region may contain no more than one component, and is identified by a corresponding constant: NORTH, SOUTH, EAST, WEST, and CENTER. When adding a component to a container with a border layout, use one of these five constants, for example:
    Panel p = new Panel();
    p.setLayout(new BorderLayout());
    p.add(new Button("Okay"), BorderLayout.SOUTH);
 
For convenience, BorderLayout interprets the absence of a string specification the same as the constant CENTER:
    Panel p2 = new Panel();
    p2.setLayout(new BorderLayout());
    p2.add(new TextArea());  // Same as p.add(new TextArea(), BorderLayout.CENTER);
 

The following image illustrate the way the borderLayout layout child component.



Public Methods
 MethodDefined by
  
BorderLayout(hgap:int = 0, vgap:int = 0)
Constructs a border layout with the specified gaps between components.
BorderLayout
  
addLayoutComponent(comp:Component, constraints:Object):void
BorderLayout
  
getHgap():int
BorderLayout
  
BorderLayout
  
BorderLayout
  
getVgap():int
BorderLayout
 Inherited
do nothing
EmptyLayout
  

Lays out the container argument using this border layout.

BorderLayout
 Inherited
return IntDimension.createBigDimension();
EmptyLayout
  
BorderLayout
  
BorderLayout
  
BorderLayout
  
setDefaultConstraints(constraints:Object):void
BorderLayout
  
setHgap(hgap:int):void
Set horizontal gap
BorderLayout
  
setVgap(vgap:int):void
Set vertical gap
BorderLayout
  
toString():String
BorderLayout
Public Constants
 ConstantDefined by
  AFTER_LAST_LINE : String = "Last"
[static]
BorderLayout
  AFTER_LINE_ENDS : String = "After"
[static]
BorderLayout
  BEFORE_FIRST_LINE : String = "First"
[static]
BorderLayout
  BEFORE_LINE_BEGINS : String = "Before"
[static]
BorderLayout
  CENTER : String = "Center"
[static] The center layout constraint (middle of container).
BorderLayout
  EAST : String = "East"
[static] The east layout constraint (right side of container).
BorderLayout
  LINE_END : String = "After"
[static]
BorderLayout
  LINE_START : String = "Before"
[static]
BorderLayout
  NORTH : String = "North"
[static] The north layout constraint (top of container).
BorderLayout
  PAGE_END : String = "Last"
[static]
BorderLayout
  PAGE_START : String = "First"
[static]
BorderLayout
  SOUTH : String = "South"
[static] The south layout constraint (bottom of container).
BorderLayout
  WEST : String = "West"
[static] The west layout constraint (left side of container).
BorderLayout
Constructor detail
BorderLayout()constructor
public function BorderLayout(hgap:int = 0, vgap:int = 0)

Constructs a border layout with the specified gaps between components. The horizontal gap is specified by hgap and the vertical gap is specified by vgap.

Parameters
hgap:int (default = 0) — hgap the horizontal gap.
 
vgap:int (default = 0) — vgap the vertical gap.
Method detail
addLayoutComponent()method
public override function addLayoutComponent(comp:Component, constraints:Object):void

Parameters
comp:Component
 
constraints:Object
getHgap()method 
public function getHgap():int

Returns
int
getLayoutAlignmentX()method 
public override function getLayoutAlignmentX(target:Container):Number

Parameters
target:Container

Returns
Number
getLayoutAlignmentY()method 
public override function getLayoutAlignmentY(target:Container):Number

Parameters
target:Container

Returns
Number
getVgap()method 
public function getVgap():int

Returns
int
layoutContainer()method 
public override function layoutContainer(target:Container):void

Lays out the container argument using this border layout.

This method actually reshapes the components in the specified container in order to satisfy the constraints of this BorderLayout object. The NORTH and SOUTH components, if any, are placed at the top and bottom of the container, respectively. The WEST and EAST components are then placed on the left and right, respectively. Finally, the CENTER object is placed in any remaining space in the middle.

Most applications do not call this method directly. This method is called when a container calls its doLayout method.

Parameters
target:Container — target the container in which to do the layout.

See also

minimumLayoutSize()method 
public override function minimumLayoutSize(target:Container):IntDimension

Parameters
target:Container

Returns
IntDimension
preferredLayoutSize()method 
public override function preferredLayoutSize(target:Container):IntDimension

Parameters
target:Container

Returns
IntDimension
removeLayoutComponent()method 
public override function removeLayoutComponent(comp:Component):void

Parameters
comp:Component
setDefaultConstraints()method 
public function setDefaultConstraints(constraints:Object):void

Parameters
constraints:Object
setHgap()method 
public function setHgap(hgap:int):void

Set horizontal gap

Parameters
hgap:int
setVgap()method 
public function setVgap(vgap:int):void

Set vertical gap

Parameters
vgap:int
toString()method 
public function toString():String

Returns
String
Constant detail
AFTER_LAST_LINEconstant
public static const AFTER_LAST_LINE:String = "Last"
AFTER_LINE_ENDSconstant 
public static const AFTER_LINE_ENDS:String = "After"
BEFORE_FIRST_LINEconstant 
public static const BEFORE_FIRST_LINE:String = "First"
BEFORE_LINE_BEGINSconstant 
public static const BEFORE_LINE_BEGINS:String = "Before"
CENTERconstant 
public static const CENTER:String = "Center"

The center layout constraint (middle of container).

EASTconstant 
public static const EAST:String = "East"

The east layout constraint (right side of container).

LINE_ENDconstant 
public static const LINE_END:String = "After"
LINE_STARTconstant 
public static const LINE_START:String = "Before"
NORTHconstant 
public static const NORTH:String = "North"

The north layout constraint (top of container).

PAGE_ENDconstant 
public static const PAGE_END:String = "Last"
PAGE_STARTconstant 
public static const PAGE_START:String = "First"
SOUTHconstant 
public static const SOUTH:String = "South"

The south layout constraint (bottom of container).

WESTconstant 
public static const WEST:String = "West"

The west layout constraint (left side of container).