allensoft.gui
Class FormLayout

java.lang.Object
  |
  +--allensoft.gui.FormLayout
All Implemented Interfaces:
java.awt.LayoutManager, java.awt.LayoutManager2

public class FormLayout
extends java.lang.Object
implements java.awt.LayoutManager2

A powerful layout manager that lays out componentents in a form fashion. Typically, a label is to the left of a field and the left edges of all fields line up. Components with even indexes are assumed to be labels and components with odd indexes are assumed to be fields.


Constructor Summary
FormLayout()
          Creates a new FlowLayout with spacings of 5 and labels left aligned and centred vertically and fields left aligned and centred vertically.
FormLayout(int nHorizSpacing, int nVertSpacing)
          Creates a new FormLayout with labels left aligned and centred vertically and fields left aligned and centred vertically.
FormLayout(int nHorizSpacing, int nVertSpacing, float fLabelHorizAlignment, float fLabelVertAlignment, float fFieldHorizAlignment, float fFieldVertAlignment)
          Creates a new FormLayout.
 
Method Summary
 void addLayoutComponent(java.awt.Component component, java.lang.Object weight)
           
 void addLayoutComponent(java.lang.String name, java.awt.Component component)
           
 float getAlignment()
           
 float getFieldHorizAlignment()
           
 float getFieldVertAlignment()
           
 int getHorizSpacing()
          Gets the spacing between labels and fields.
 float getLabelHorizAlignment()
          Gets the horizontal alignment for labels.
 float getLabelVertAlignment()
           
 float getLayoutAlignmentX(java.awt.Container container)
           
 float getLayoutAlignmentY(java.awt.Container container)
           
 int getVertSpacing()
          Gets the vertical spacing between fields.
 float getWeight(java.awt.Component component)
           
 void invalidateLayout(java.awt.Container container)
           
 void layoutContainer(java.awt.Container container)
           
 java.awt.Dimension maximumLayoutSize(java.awt.Container container)
           
 java.awt.Dimension minimumLayoutSize(java.awt.Container container)
           
 java.awt.Dimension preferredLayoutSize(java.awt.Container container)
           
 void removeLayoutComponent(java.awt.Component component)
           
 void setAlignment(float f)
           
 void setFieldHorizAlignment(float f)
           
 void setFieldVertAlignment(float f)
           
 void setHorizSpacing(int n)
          Sets the spacing between labels and fields.
 void setLabelHorizAlignment(float f)
          Sets the horizontal alignment for labels.
 void setLabelVertAlignment(float f)
           
 void setVertSpacing(int n)
          Gets the vertical spacing between fields.
 void setWeight(java.awt.Component component, float fWeight)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FormLayout

public FormLayout(int nHorizSpacing,
                  int nVertSpacing,
                  float fLabelHorizAlignment,
                  float fLabelVertAlignment,
                  float fFieldHorizAlignment,
                  float fFieldVertAlignment)
Creates a new FormLayout.
Parameters:
nHorizSpacing - the spacing between a label and a field
nVertSpacing - the spacing between fields
fLabelHorizAlignment - see setLabelHorizAlignment(float)
fLabelVertAlignment - see setLabelVertAlignment(float)
fFieldHorizAlignment - see setFieldHorizAlignment(float)
fFieldVertAlignment - see setFieldVertAlignment(float)

FormLayout

public FormLayout(int nHorizSpacing,
                  int nVertSpacing)
Creates a new FormLayout with labels left aligned and centred vertically and fields left aligned and centred vertically.
Parameters:
nHorizSpacing - the spacing between a label and a field
nVertSpacing - the spacing between fields

FormLayout

public FormLayout()
Creates a new FlowLayout with spacings of 5 and labels left aligned and centred vertically and fields left aligned and centred vertically.
Method Detail

getHorizSpacing

public int getHorizSpacing()
Gets the spacing between labels and fields.

setHorizSpacing

public void setHorizSpacing(int n)
Sets the spacing between labels and fields.

getVertSpacing

public int getVertSpacing()
Gets the vertical spacing between fields.

setVertSpacing

public void setVertSpacing(int n)
Gets the vertical spacing between fields.

getLabelHorizAlignment

public float getLabelHorizAlignment()
Gets the horizontal alignment for labels. This specifies how the labels should be aligned horizontally. The value should be a number between 0 and 1 where 0 represents left alignment, 1 is right alignment, 0.5 is centered, etc.

setLabelHorizAlignment

public void setLabelHorizAlignment(float f)
Sets the horizontal alignment for labels. This specifies how the labels should be aligned horizontally. The value should be a number between 0 and 1 where 0 represents left alignment, 1 is right alignment, 0.5 is centered, etc.

getLabelVertAlignment

public float getLabelVertAlignment()

setLabelVertAlignment

public void setLabelVertAlignment(float f)

getFieldHorizAlignment

public float getFieldHorizAlignment()

setFieldHorizAlignment

public void setFieldHorizAlignment(float f)

getFieldVertAlignment

public float getFieldVertAlignment()

setFieldVertAlignment

public void setFieldVertAlignment(float f)

getAlignment

public float getAlignment()

setAlignment

public void setAlignment(float f)

getWeight

public float getWeight(java.awt.Component component)

setWeight

public void setWeight(java.awt.Component component,
                      float fWeight)

addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component component)
Specified by:
addLayoutComponent in interface java.awt.LayoutManager

addLayoutComponent

public void addLayoutComponent(java.awt.Component component,
                               java.lang.Object weight)
Specified by:
addLayoutComponent in interface java.awt.LayoutManager2

removeLayoutComponent

public void removeLayoutComponent(java.awt.Component component)
Specified by:
removeLayoutComponent in interface java.awt.LayoutManager

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container container)
Specified by:
preferredLayoutSize in interface java.awt.LayoutManager

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container container)
Specified by:
minimumLayoutSize in interface java.awt.LayoutManager

maximumLayoutSize

public java.awt.Dimension maximumLayoutSize(java.awt.Container container)
Specified by:
maximumLayoutSize in interface java.awt.LayoutManager2

layoutContainer

public void layoutContainer(java.awt.Container container)
Specified by:
layoutContainer in interface java.awt.LayoutManager

getLayoutAlignmentX

public float getLayoutAlignmentX(java.awt.Container container)
Specified by:
getLayoutAlignmentX in interface java.awt.LayoutManager2

getLayoutAlignmentY

public float getLayoutAlignmentY(java.awt.Container container)
Specified by:
getLayoutAlignmentY in interface java.awt.LayoutManager2

invalidateLayout

public void invalidateLayout(java.awt.Container container)
Specified by:
invalidateLayout in interface java.awt.LayoutManager2