Packageorg.aswing
Classpublic class FlowLayout
InheritanceFlowLayout Inheritance EmptyLayout
SubclassesFlowWrapLayout

A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. Flow layouts are typically used to arrange buttons in a panel. It will arrange buttons left to right until no more buttons fit on the same line. Each line is centered.

For example, the following picture shows an applet using the flow layout manager (its default layout manager) to position three buttons:

A flow layout lets each component assume its natural (preferred) size.



Protected Properties
 PropertyDefined by
  align : int
align is the property that determines how each row distributes empty space.
FlowLayout
  hgap : int
The flow layout manager allows a seperation of components with gaps.
FlowLayout
  margin : Boolean
whether or not the gap will margin around
FlowLayout
  vgap : int
The flow layout manager allows a seperation of components with gaps.
FlowLayout
Public Methods
 MethodDefined by
  
FlowLayout(align:int, hgap:int = 5, vgap:int = 5, margin:Boolean = true)

Creates a new flow layout manager with the indicated alignment and the indicated horizontal and vertical gaps.

FlowLayout
 Inherited
addLayoutComponent(comp:Component, constraints:Object):void
Do nothing Adds the specified component to the layout, using the specified constraint object.
EmptyLayout
  
Gets the alignment for this layout.
FlowLayout
  
getHgap():int
Gets the horizontal gap between components.
FlowLayout
 Inherited
return 0
EmptyLayout
 Inherited
return 0
EmptyLayout
  
getVgap():int
Gets the vertical gap between components.
FlowLayout
 Inherited
do nothing
EmptyLayout
  
isMargin():Boolean
Returns whether or not the gap will margin around.
FlowLayout
  
Lays out the container.
FlowLayout
 Inherited
return IntDimension.createBigDimension();
EmptyLayout
  
Returns the minimum dimensions needed to layout the visible components contained in the specified target container.
FlowLayout
  
Returns the preferred dimensions for this layout given the visible components in the specified target container.
FlowLayout
 Inherited
Do nothing Removes the specified component from the layout.
EmptyLayout
  
setAlignment(align:int):void
Sets the alignment for this layout.
FlowLayout
  
setHgap(hgap:int):void
Sets the horizontal gap between components.
FlowLayout
  
setMargin(b:Boolean):void
Sets whether or not the gap will margin around.
FlowLayout
  
setVgap(vgap:int):void
Sets the vertical gap between components.
FlowLayout
  
toString():String
Returns a string representation of this FlowLayout object and its values.
FlowLayout
Public Constants
 ConstantDefined by
  CENTER : int = 0
[static] This value indicates that each row of components should be centered.
FlowLayout
  LEFT : int = 2
[static] This value indicates that each row of components should be left-justified.
FlowLayout
  RIGHT : int = 4
[static] This value indicates that each row of components should be right-justified.
FlowLayout
Property detail
alignproperty
protected var align:int

align is the property that determines how each row distributes empty space. It can be one of the following values:

See also

hgapproperty 
protected var hgap:int

The flow layout manager allows a seperation of components with gaps. The horizontal gap will specify the space between components.

See also

marginproperty 
protected var margin:Boolean

whether or not the gap will margin around

vgapproperty 
protected var vgap:int

The flow layout manager allows a seperation of components with gaps. The vertical gap will specify the space between rows.

See also

Constructor detail
FlowLayout()constructor
public function FlowLayout(align:int, hgap:int = 5, vgap:int = 5, margin:Boolean = true)

Creates a new flow layout manager with the indicated alignment and the indicated horizontal and vertical gaps.

The value of the alignment argument must be one of FlowLayout.LEFT, FlowLayout.RIGHT,or FlowLayout.CENTER. Parameters
align:int — align the alignment value, default is LEFT
 
hgap:int (default = 5) — hgap the horizontal gap between components, default 5
 
vgap:int (default = 5) — vgap the vertical gap between components, default 5
 
margin:Boolean (default = true) — margin whether or not the gap will margin around
Method detail
getAlignment()method
public function getAlignment():int

Gets the alignment for this layout. Possible values are FlowLayout.LEFT,FlowLayout.RIGHT, FlowLayout.CENTER,

Returns
int — the alignment value for this layout

See also

getHgap()method 
public function getHgap():int

Gets the horizontal gap between components.

Returns
int — the horizontal gap between components

See also

getVgap()method 
public function getVgap():int

Gets the vertical gap between components.

Returns
int — the vertical gap between components

See also

isMargin()method 
public function isMargin():Boolean

Returns whether or not the gap will margin around.

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

Lays out the container. This method lets each component take its preferred size by reshaping the components in the target container in order to satisfy the alignment of this FlowLayout object.

Parameters
target:Container — the specified component being laid out

See also

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

Returns the minimum dimensions needed to layout the visible components contained in the specified target container.

Parameters
target:Container — the component which needs to be laid out

Returns
IntDimension — the minimum dimensions to lay out the subcomponents of the specified container

See also

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

Returns the preferred dimensions for this layout given the visible components in the specified target container.

Parameters
target:Container — the component which needs to be laid out

Returns
IntDimension — the preferred dimensions to lay out the subcomponents of the specified container

See also

setAlignment()method 
public function setAlignment(align:int):void

Sets the alignment for this layout. Possible values are

Parameters
align:int — align one of the alignment values shown above

See also

setHgap()method 
public function setHgap(hgap:int):void

Sets the horizontal gap between components.

Parameters
hgap:int — the horizontal gap between components

See also

setMargin()method 
public function setMargin(b:Boolean):void

Sets whether or not the gap will margin around.

Parameters
b:Boolean
setVgap()method 
public function setVgap(vgap:int):void

Sets the vertical gap between components.

Parameters
vgap:int — the vertical gap between components

See also

toString()method 
public function toString():String

Returns a string representation of this FlowLayout object and its values.

Returns
String — a string representation of this layout
Constant detail
CENTERconstant
public static const CENTER:int = 0

This value indicates that each row of components should be centered.

LEFTconstant 
public static const LEFT:int = 2

This value indicates that each row of components should be left-justified.

RIGHTconstant 
public static const RIGHT:int = 4

This value indicates that each row of components should be right-justified.