net.sf.swinglib.layout
Class CompactGridLayout

java.lang.Object
  extended by net.sf.swinglib.layout.CompactGridLayout
All Implemented Interfaces:
LayoutManager, LayoutManager2

public class CompactGridLayout
extends Object
implements LayoutManager2

A layout manager designed for building input forms. It provides the following features:

Version:
1.0

Constructor Summary
CompactGridLayout(int cols)
          Basic constructor, which allows user to specify the number of columns and nothing else.
CompactGridLayout(int cols, int hGap, int vGap)
          Constructor that allows specification of horizontal and vertical gaps between components.
CompactGridLayout(int cols, int hGap, int vGap, float hAlign, float vAlign)
          Constructor that allows specification of horizontal and vertical gaps between components, as well as component alignment within cells.
 
Method Summary
 void addLayoutComponent(Component comp, Object cons)
          Adds a component to the layout, associating it with the specified constraints object.
 void addLayoutComponent(String name, Component comp)
          Deprecated. use addLayoutComponent(Component,Object)
 float getLayoutAlignmentX(Container target)
          Returns a default horizontal alignment value for this container.
 float getLayoutAlignmentY(Container target)
          Returns a default vertical alignment value for this container.
 void invalidateLayout(Container target)
          Invalidates the current cached information for this layout, and recalculates the row heights and column widths.
 void layoutContainer(Container target)
          Lays out the container.
 Dimension maximumLayoutSize(Container target)
          Returns the maximum size of this layout, which is the same as its preferred size.
 Dimension minimumLayoutSize(Container target)
          Returns the minimum size of this layout, based on its components.
 Dimension preferredLayoutSize(Container target)
          Returns the preferred size of this layout, based on its components.
 void removeLayoutComponent(Component comp)
          Removes a component from the layout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompactGridLayout

public CompactGridLayout(int cols)
Basic constructor, which allows user to specify the number of columns and nothing else. Vertical and horizontal gaps both default to 0, and component alignment defaults to left-horizontal and center-vertical.

Parameters:
cols - Number of columns in the layout.

CompactGridLayout

public CompactGridLayout(int cols,
                         int hGap,
                         int vGap)
Constructor that allows specification of horizontal and vertical gaps between components. Alignment defaults to left-horizontal and center- vertical.

Parameters:
cols - Number of columns in the layout.
hGap - Horizontal gap between components, in pixels.
vGap - Vertical gap between components, in pixels.

CompactGridLayout

public CompactGridLayout(int cols,
                         int hGap,
                         int vGap,
                         float hAlign,
                         float vAlign)
Constructor that allows specification of horizontal and vertical gaps between components, as well as component alignment within cells.

Parameters:
cols - Number of columns in the layout.
hGap - Horizontal gap between components, in pixels.
vGap - Vertical gap between components, in pixels.
hAlign - Horizontal alignment of components within cell.
vAlign - Vertical alignment of components within cell.
Method Detail

addLayoutComponent

public void addLayoutComponent(Component comp,
                               Object cons)
Adds a component to the layout, associating it with the specified constraints object.

Specified by:
addLayoutComponent in interface LayoutManager2
Parameters:
comp - The component to add.
cons - A constraints object to go with this component. Since this layout manager does not use constraints, this parameter is ignored, and may be null

addLayoutComponent

public void addLayoutComponent(String name,
                               Component comp)
Deprecated. use addLayoutComponent(Component,Object)

Adds a component to the layout, associating it with the specified constraints object.

Specified by:
addLayoutComponent in interface LayoutManager
Parameters:
comp - The component to add.
cons - A constraints object to go with this component. Since this layout manager does not use constraints, this parameter is ignored, and may be null

removeLayoutComponent

public void removeLayoutComponent(Component comp)
Removes a component from the layout.

Specified by:
removeLayoutComponent in interface LayoutManager

invalidateLayout

public void invalidateLayout(Container target)
Invalidates the current cached information for this layout, and recalculates the row heights and column widths.

Specified by:
invalidateLayout in interface LayoutManager2

preferredLayoutSize

public Dimension preferredLayoutSize(Container target)
Returns the preferred size of this layout, based on its components.

Specified by:
preferredLayoutSize in interface LayoutManager

minimumLayoutSize

public Dimension minimumLayoutSize(Container target)
Returns the minimum size of this layout, based on its components.

Specified by:
minimumLayoutSize in interface LayoutManager

maximumLayoutSize

public Dimension maximumLayoutSize(Container target)
Returns the maximum size of this layout, which is the same as its preferred size.

Specified by:
maximumLayoutSize in interface LayoutManager2

layoutContainer

public void layoutContainer(Container target)
Lays out the container.

Specified by:
layoutContainer in interface LayoutManager

getLayoutAlignmentX

public float getLayoutAlignmentX(Container target)
Returns a default horizontal alignment value for this container.

Specified by:
getLayoutAlignmentX in interface LayoutManager2

getLayoutAlignmentY

public float getLayoutAlignmentY(Container target)
Returns a default vertical alignment value for this container.

Specified by:
getLayoutAlignmentY in interface LayoutManager2