com.alee.extended.layout
Class FormLayout

java.lang.Object
  extended by com.alee.extended.layout.AbstractLayoutManager
      extended by com.alee.extended.layout.FormLayout
All Implemented Interfaces:
java.awt.LayoutManager, java.awt.LayoutManager2

public class FormLayout
extends AbstractLayoutManager

Author:
Mikle Garin

Field Summary
static java.lang.String CENTER
           
static java.lang.String FILL
           
protected  boolean fillLeftSide
          Whether left side of the form should fill all the free space given by container or not.
protected  boolean fillLeftSideHeight
          Whether component in each form row on the left side of the form should fill given height or not by default.
protected  boolean fillRightSide
          Whether right side of the form should fill all the free space given by container or not.
protected  boolean fillRightSideHeight
          Whether component in each form row on the right side of the form should fill given height or not by default.
protected  int horizontalGap
          Horizontal gap between columns.
protected  java.util.Map<java.awt.Component,java.lang.String> layoutConstraints
          Added component constraints.
static java.lang.String LEFT
          Form elements constraint constants.
protected  int leftVerticalAlignment
          Default vertical alignment of components on the left side of the form.
static java.lang.String RIGHT
           
protected  int rightVerticalAlignment
          Default vertical alignment of components on the right side of the form.
protected  int verticalGap
          Vertical gap between rows.
 
Constructor Summary
FormLayout()
          Constructs new FormLayout with zero gaps and filled right side.
FormLayout(boolean fillLeftSide, boolean fillRightSide)
          Constructs new FormLayout with zero gaps and specified left/right side fills.
FormLayout(boolean fillLeftSide, boolean fillRightSide, int horizontalGap, int verticalGap)
          Constructs new FormLayout with specified gaps and left/right side fills.
FormLayout(int horizontalGap, int verticalGap)
          Constructs new FormLayout with specified gaps and filled right side.
 
Method Summary
 void addComponent(java.awt.Component component, java.lang.Object constraints)
          Caled when component added into container with this layout.
 int getHorizontalGap()
          Returns horizontal gap between columns.
 int getLeftVerticalAlignment()
          Returns default vertical alignment of components on the left side of the form.
 int getRightVerticalAlignment()
          Returns default vertical alignment of components on the right side of the form.
protected  int getSideY(boolean leftSide, int rowY, int rowHeight, int componentHeight)
          Returns component Y coordinate for the specified side and other settings.
 int getVerticalGap()
          Returns vertical gap between rows.
 boolean isFillLeftSide()
          Returns whether left side of the form should fill all the free space given by container or not.
 boolean isFillLeftSideHeight()
          Returns whether component in each form row on the left side of the form should fill given height or not.
 boolean isFillRightSide()
          Returns whether right side of the form should fill all the free space given by container or not.
 boolean isFillRightSideHeight()
          Returns whether component in each form row on the right side of the form should fill given height or not.
 void layoutContainer(java.awt.Container parent)
          
 java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
          
 void removeComponent(java.awt.Component component)
          Called when component removed from container with this layout.
 void setFillLeftSide(boolean fillLeftSide)
          Sets whether left side of the form should fill all the free space given by container or not.
 void setFillLeftSideHeight(boolean fillLeftSideHeight)
          Sets whether component in each form row on the left side of the form should fill given height or not.
 void setFillRightSide(boolean fillRightSide)
          Sets whether right side of the form should fill all the free space given by container or not.
 void setFillRightSideHeight(boolean fillRightSideHeight)
          Sets whether component in each form row on the right side of the form should fill given height or not.
 void setHorizontalGap(int horizontalGap)
          Sets horizontal gap between columns.
 void setLeftVerticalAlignment(int leftVerticalAlignment)
          Sets default vertical alignment of components on the left side of the form.
 void setRightVerticalAlignment(int rightVerticalAlignment)
          Sets default vertical alignment of components on the right side of the form.
 void setVerticalGap(int verticalGap)
          Sets vertical gap between rows.
 
Methods inherited from class com.alee.extended.layout.AbstractLayoutManager
addLayoutComponent, addLayoutComponent, getLayoutAlignmentX, getLayoutAlignmentY, invalidateLayout, maximumLayoutSize, minimumLayoutSize, removeLayoutComponent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LEFT

public static final java.lang.String LEFT
Form elements constraint constants.

See Also:
Constant Field Values

CENTER

public static final java.lang.String CENTER
See Also:
Constant Field Values

RIGHT

public static final java.lang.String RIGHT
See Also:
Constant Field Values

FILL

public static final java.lang.String FILL
See Also:
Constant Field Values

fillLeftSide

protected boolean fillLeftSide
Whether left side of the form should fill all the free space given by container or not.


fillRightSide

protected boolean fillRightSide
Whether right side of the form should fill all the free space given by container or not.


fillLeftSideHeight

protected boolean fillLeftSideHeight
Whether component in each form row on the left side of the form should fill given height or not by default.


fillRightSideHeight

protected boolean fillRightSideHeight
Whether component in each form row on the right side of the form should fill given height or not by default.


leftVerticalAlignment

protected int leftVerticalAlignment
Default vertical alignment of components on the left side of the form. This is applied only if left side components do not fill the whole row height.


rightVerticalAlignment

protected int rightVerticalAlignment
Default vertical alignment of components on the right side of the form. This is applied only if right side components do not fill the whole row height.


horizontalGap

protected int horizontalGap
Horizontal gap between columns.


verticalGap

protected int verticalGap
Vertical gap between rows.


layoutConstraints

protected java.util.Map<java.awt.Component,java.lang.String> layoutConstraints
Added component constraints.

Constructor Detail

FormLayout

public FormLayout()
Constructs new FormLayout with zero gaps and filled right side.


FormLayout

public FormLayout(boolean fillLeftSide,
                  boolean fillRightSide)
Constructs new FormLayout with zero gaps and specified left/right side fills.

Parameters:
fillLeftSide - whether left side of the form should fill all the free space given by container or not
fillRightSide - whether right side of the form should fill all the free space given by container or not

FormLayout

public FormLayout(int horizontalGap,
                  int verticalGap)
Constructs new FormLayout with specified gaps and filled right side.

Parameters:
horizontalGap - horizontal gap between columns
verticalGap - vertical gap between rows

FormLayout

public FormLayout(boolean fillLeftSide,
                  boolean fillRightSide,
                  int horizontalGap,
                  int verticalGap)
Constructs new FormLayout with specified gaps and left/right side fills.

Parameters:
fillLeftSide - whether left side of the form should fill all the free space given by container or not
fillRightSide - whether right side of the form should fill all the free space given by container or not
horizontalGap - horizontal gap between columns
verticalGap - vertical gap between rows
Method Detail

isFillLeftSide

public boolean isFillLeftSide()
Returns whether left side of the form should fill all the free space given by container or not.

Returns:
true if left side of the form should fill all the free space given by container, false otherwise

setFillLeftSide

public void setFillLeftSide(boolean fillLeftSide)
Sets whether left side of the form should fill all the free space given by container or not.

Parameters:
fillLeftSide - whether left side of the form should fill all the free space given by container or not

isFillRightSide

public boolean isFillRightSide()
Returns whether right side of the form should fill all the free space given by container or not.

Returns:
true if right side of the form should fill all the free space given by container, false otherwise

setFillRightSide

public void setFillRightSide(boolean fillRightSide)
Sets whether right side of the form should fill all the free space given by container or not.

Parameters:
fillRightSide - whether right side of the form should fill all the free space given by container or not

isFillLeftSideHeight

public boolean isFillLeftSideHeight()
Returns whether component in each form row on the left side of the form should fill given height or not.

Returns:
true if component in each form row on the left side of the form should fill given height, false otherwise

setFillLeftSideHeight

public void setFillLeftSideHeight(boolean fillLeftSideHeight)
Sets whether component in each form row on the left side of the form should fill given height or not.

Parameters:
fillLeftSideHeight - whether component in each form row on the left side of the form should fill given height or not

isFillRightSideHeight

public boolean isFillRightSideHeight()
Returns whether component in each form row on the right side of the form should fill given height or not.

Returns:
true if component in each form row on the right side of the form should fill given height, false otherwise

setFillRightSideHeight

public void setFillRightSideHeight(boolean fillRightSideHeight)
Sets whether component in each form row on the right side of the form should fill given height or not.

Parameters:
fillRightSideHeight - whether component in each form row on the right side of the form should fill given height or not

getLeftVerticalAlignment

public int getLeftVerticalAlignment()
Returns default vertical alignment of components on the left side of the form.

Returns:
default vertical alignment of components on the left side of the form

setLeftVerticalAlignment

public void setLeftVerticalAlignment(int leftVerticalAlignment)
Sets default vertical alignment of components on the left side of the form.

Parameters:
leftVerticalAlignment - default vertical alignment of components on the left side of the form

getRightVerticalAlignment

public int getRightVerticalAlignment()
Returns default vertical alignment of components on the right side of the form.

Returns:
default vertical alignment of components on the right side of the form

setRightVerticalAlignment

public void setRightVerticalAlignment(int rightVerticalAlignment)
Sets default vertical alignment of components on the right side of the form.

Parameters:
rightVerticalAlignment - default vertical alignment of components on the right side of the form

getHorizontalGap

public int getHorizontalGap()
Returns horizontal gap between columns.

Returns:
horizontal gap between columns

setHorizontalGap

public void setHorizontalGap(int horizontalGap)
Sets horizontal gap between columns.

Parameters:
horizontalGap - horizontal gap between columns

getVerticalGap

public int getVerticalGap()
Returns vertical gap between rows.

Returns:
vertical gap between rows

setVerticalGap

public void setVerticalGap(int verticalGap)
Sets vertical gap between rows.

Parameters:
verticalGap - vertical gap between rows

addComponent

public void addComponent(java.awt.Component component,
                         java.lang.Object constraints)
Caled when component added into container with this layout.

Overrides:
addComponent in class AbstractLayoutManager
Parameters:
component - added component
constraints - component constraints

removeComponent

public void removeComponent(java.awt.Component component)
Called when component removed from container with this layout.

Overrides:
removeComponent in class AbstractLayoutManager
Parameters:
component - removed component

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)


layoutContainer

public void layoutContainer(java.awt.Container parent)


getSideY

protected int getSideY(boolean leftSide,
                       int rowY,
                       int rowHeight,
                       int componentHeight)
Returns component Y coordinate for the specified side and other settings.

Parameters:
leftSide - whether component is on the left side of the form or not
rowY - row Y coordinate
rowHeight - row height
componentHeight - component preferred height
Returns:
component Y coordinate