Packageorg.aswing
Classpublic class BoxLayout
InheritanceBoxLayout Inheritance EmptyLayout

A layout manager that allows multiple components to be arranged either vertically or horizontally. The components will not be wrapped. The width, height, preferredWidth,preferredHeight doesn't affect the way this layout manager layout the components. Note, it does not work the same way as Java swing boxlayout does.

If this boxlayout is set to X_AXIS, it will layout the child componnets evenly regardless the value of width,height,preferredWidth,preferredHeight. The height of the child components is the same as the parent container. The following picture illustrate this:



It works the same way when it is set to Y_AXIS.


Note that this layout will first subtract all of the gaps before it evenly layout the components. If you have a container that is 100 pixel in width with 5 child components, the layout manager is boxlayout, and set to X_AXIS, the gap is 20. You would not see any child componnet in visual. Because the layout mananager will first subtract 20(gap)(component) =100 pixels from the visual area. Then, each component's width would be 0. Pay attention to this when you use this layout manager.



Public Methods
 MethodDefined by
  
BoxLayout(axis:int, gap:int = 0)
BoxLayout
 Inherited
addLayoutComponent(comp:Component, constraints:Object):void
Do nothing Adds the specified component to the layout, using the specified constraint object.
EmptyLayout
  
getAxis():int
Gets axis.
BoxLayout
  
getGap():int
Gets gap.
BoxLayout
  
return 0.5
BoxLayout
  
return 0.5
BoxLayout
 Inherited
do nothing
EmptyLayout
  
BoxLayout
  
BoxLayout
  
BoxLayout
  
BoxLayout
 Inherited
Do nothing Removes the specified component from the layout.
EmptyLayout
  
setAxis(axis:int):void
Sets new axis.
BoxLayout
  
setGap(gap:int = 0):void
Sets new gap.
BoxLayout
Public Constants
 ConstantDefined by
  X_AXIS : int = 0
[static] Specifies that components should be laid out left to right.
BoxLayout
  Y_AXIS : int = 1
[static] Specifies that components should be laid out top to bottom.
BoxLayout
Constructor detail
BoxLayout()constructor
public function BoxLayout(axis:int, gap:int = 0)

Parameters
axis:int — (optional)the layout axis, default is X_AXIS
 
gap:int (default = 0) — (optional)the gap between children, default is 0

See also

Method detail
getAxis()method
public function getAxis():int

Gets axis.

Returns
int — axis
getGap()method 
public function getGap():int

Gets gap.

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

return 0.5

Parameters
target:Container

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

return 0.5

Parameters
target:Container

Returns
Number
layoutContainer()method 
public override function layoutContainer(target:Container):voidParameters
target:Container
maximumLayoutSize()method 
public override function maximumLayoutSize(target:Container):IntDimensionParameters
target:Container

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

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

Returns
IntDimension
setAxis()method 
public function setAxis(axis:int):void

Sets new axis.

Parameters
axis:int — new axis default is X_AXIS
setGap()method 
public function setGap(gap:int = 0):void

Sets new gap.

Parameters
gap:int (default = 0) — new gap
Constant detail
X_AXISconstant
public static const X_AXIS:int = 0

Specifies that components should be laid out left to right.

Y_AXISconstant 
public static const Y_AXIS:int = 1

Specifies that components should be laid out top to bottom.