com.jgoodies.forms.builder
Class AbstractFormBuilder

java.lang.Object
  extended by com.jgoodies.forms.builder.AbstractFormBuilder
Direct Known Subclasses:
PanelBuilder

public abstract class AbstractFormBuilder
extends java.lang.Object

An abstract class that minimizes the effort required to implement non-visual builders that use the FormLayout.

Builders hide details of the FormLayout and provide convenience behavior that assists you in constructing a form. This class provides a cell cursor that helps you traverse a form while you add components. Also, it offers several methods to append custom and logical columns and rows.

Version:
$Revision: 1.1 $
Author:
Karsten Lentzsch
See Also:
ButtonBarBuilder, ButtonStackBuilder, PanelBuilder, com.jgoodies.forms.extras.I15dPanelBuilder, com.jgoodies.forms.extras.DefaultFormBuilder

Constructor Summary
AbstractFormBuilder(java.awt.Container container, FormLayout layout)
          Constructs an instance of AbstractFormBuilder for the given container and form layout.
 
Method Summary
 java.awt.Component add(java.awt.Component component)
          Adds a component to the container using the default cell constraints.
 java.awt.Component add(java.awt.Component component, CellConstraints cellConstraints)
          Adds a component to the panel using the given cell constraints.
 java.awt.Component add(java.awt.Component component, java.lang.String encodedCellConstraints)
          Adds a component to the panel using the given encoded cell constraints.
 void appendColumn(ColumnSpec columnSpec)
          Appends the given column specification to the builder's layout.
 void appendColumn(java.lang.String encodedColumnSpec)
          Appends a column specification to the builder's layout that represents the given string encoding.
 void appendGlueColumn()
          Appends a glue column.
 void appendGlueRow()
          Appends a glue row.
 void appendRelatedComponentsGapColumn()
          Appends a column that is the default gap for related components.
 void appendRelatedComponentsGapRow()
          Appends a row that is the default gap for related components.
 void appendRow(RowSpec rowSpec)
          Appends the given row specification to the builder's layout.
 void appendRow(java.lang.String encodedRowSpec)
          Appends a row specification to the builder's layout that represents the given string encoding.
 void appendUnrelatedComponentsGapColumn()
          Appends a column that is the default gap for unrelated components.
 void appendUnrelatedComponentsGapRow()
          Appends a row that is the default gap for unrelated components.
 int getColumn()
          Returns the cursor's column.
 int getColumnCount()
          Returns the number of columns in the form.
 java.awt.Container getContainer()
          Returns the container used to build the form.
 FormLayout getLayout()
          Returns the instance of FormLayout used to build this form.
 int getRow()
          Returns the cursor's row.
 int getRowCount()
          Returns the number of rows in the form.
 boolean isLeftToRight()
          Returns whether this builder fills the form left-to-right or right-to-left.
 void nextColumn()
          Moves to the next column, does the same as #nextColumn(1).
 void nextColumn(int columns)
          Moves to the next column.
 void nextLine()
          Moves to the next line: increases the row and resets the column; does the same as #nextLine(1).
 void nextLine(int lines)
          Moves the cursor down several lines: increases the row by the specified number of lines and sets the cursor to the leading column.
 void nextRow()
          Increases the row by one; does the same as #nextRow(1).
 void nextRow(int rows)
          Increases the row by the specified rows.
 void setAlignment(CellConstraints.Alignment hAlign, CellConstraints.Alignment vAlign)
          Sets the horizontal and vertical alignment.
 void setBounds(int column, int row, int columnSpan, int rowSpan)
          Sets the cell bounds (location and extent) to the given column, row, column span and row span.
 void setColumn(int column)
          Sets the cursor to the given column.
 void setColumnSpan(int columnSpan)
          Sets the cursor's column span.
 void setExtent(int columnSpan, int rowSpan)
          Sets the cursor's extent to the given column span and row span.
 void setHAlignment(CellConstraints.Alignment alignment)
          Sets the horizontal alignment.
 void setLeftToRight(boolean b)
          Sets the form fill direction to left-to-right or right-to-left.
 void setOrigin(int column, int row)
          Sets the cursor's origin to the given column and row.
 void setRow(int row)
          Sets the cursor to the given row.
 void setRowSpan(int rowSpan)
          Sets the cursor's row span.
 void setVAlignment(CellConstraints.Alignment alignment)
          Sets the vertical alignment.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractFormBuilder

public AbstractFormBuilder(java.awt.Container container,
                           FormLayout layout)
Constructs an instance of AbstractFormBuilder for the given container and form layout.

Parameters:
container - the layout container
layout - the FormLayout to use
Method Detail

getContainer

public final java.awt.Container getContainer()
Returns the container used to build the form.

Returns:
the layout container

getLayout

public final FormLayout getLayout()
Returns the instance of FormLayout used to build this form.

Returns:
the FormLayout

getColumnCount

public final int getColumnCount()
Returns the number of columns in the form.

Returns:
the number of columns

getRowCount

public final int getRowCount()
Returns the number of rows in the form.

Returns:
the number of rows

isLeftToRight

public final boolean isLeftToRight()
Returns whether this builder fills the form left-to-right or right-to-left.

Returns:
true indicates left-to-right, false indicates right-to-left

setLeftToRight

public final void setLeftToRight(boolean b)
Sets the form fill direction to left-to-right or right-to-left.

Parameters:
b - true indicates left-to-right, false right-to-left

getColumn

public final int getColumn()
Returns the cursor's column.

Returns:
the cursor's column

setColumn

public final void setColumn(int column)
Sets the cursor to the given column.

Parameters:
column - the cursor's new column index

getRow

public final int getRow()
Returns the cursor's row.

Returns:
the cursor's row

setRow

public final void setRow(int row)
Sets the cursor to the given row.

Parameters:
row - the cursor's new row index

setColumnSpan

public final void setColumnSpan(int columnSpan)
Sets the cursor's column span.

Parameters:
columnSpan - the cursor's new column span (grid width)

setRowSpan

public final void setRowSpan(int rowSpan)
Sets the cursor's row span.

Parameters:
rowSpan - the cursor's new row span (grid height)

setOrigin

public final void setOrigin(int column,
                            int row)
Sets the cursor's origin to the given column and row.

Parameters:
column - the new column index
row - the new row index

setExtent

public final void setExtent(int columnSpan,
                            int rowSpan)
Sets the cursor's extent to the given column span and row span.

Parameters:
columnSpan - the new column span (grid width)
rowSpan - the new row span (grid height)

setBounds

public final void setBounds(int column,
                            int row,
                            int columnSpan,
                            int rowSpan)
Sets the cell bounds (location and extent) to the given column, row, column span and row span.

Parameters:
column - the new column index (grid x)
row - the new row index (grid y)
columnSpan - the new column span (grid width)
rowSpan - the new row span (grid height)

nextColumn

public final void nextColumn()
Moves to the next column, does the same as #nextColumn(1).


nextColumn

public final void nextColumn(int columns)
Moves to the next column.

Parameters:
columns - number of columns to move

nextRow

public final void nextRow()
Increases the row by one; does the same as #nextRow(1).


nextRow

public final void nextRow(int rows)
Increases the row by the specified rows.

Parameters:
rows - number of rows to move

nextLine

public final void nextLine()
Moves to the next line: increases the row and resets the column; does the same as #nextLine(1).


nextLine

public final void nextLine(int lines)
Moves the cursor down several lines: increases the row by the specified number of lines and sets the cursor to the leading column.

Parameters:
lines - number of rows to move

setHAlignment

public final void setHAlignment(CellConstraints.Alignment alignment)
Sets the horizontal alignment.

Parameters:
alignment - the new horizontal alignment

setVAlignment

public final void setVAlignment(CellConstraints.Alignment alignment)
Sets the vertical alignment.

Parameters:
alignment - the new vertical alignment

setAlignment

public final void setAlignment(CellConstraints.Alignment hAlign,
                               CellConstraints.Alignment vAlign)
Sets the horizontal and vertical alignment.

Parameters:
hAlign - the new horizontal alignment
vAlign - the new vertical alignment

appendColumn

public final void appendColumn(ColumnSpec columnSpec)
Appends the given column specification to the builder's layout.

Parameters:
columnSpec - the column specification to append

appendColumn

public final void appendColumn(java.lang.String encodedColumnSpec)
Appends a column specification to the builder's layout that represents the given string encoding.

Parameters:
encodedColumnSpec - the column specification to append

appendGlueColumn

public final void appendGlueColumn()
Appends a glue column.


appendRelatedComponentsGapColumn

public final void appendRelatedComponentsGapColumn()
Appends a column that is the default gap for related components.


appendUnrelatedComponentsGapColumn

public final void appendUnrelatedComponentsGapColumn()
Appends a column that is the default gap for unrelated components.


appendRow

public final void appendRow(RowSpec rowSpec)
Appends the given row specification to the builder's layout.

Parameters:
rowSpec - the row specification to append

appendRow

public final void appendRow(java.lang.String encodedRowSpec)
Appends a row specification to the builder's layout that represents the given string encoding.

Parameters:
encodedRowSpec - the row specification to append

appendGlueRow

public final void appendGlueRow()
Appends a glue row.


appendRelatedComponentsGapRow

public final void appendRelatedComponentsGapRow()
Appends a row that is the default gap for related components.


appendUnrelatedComponentsGapRow

public final void appendUnrelatedComponentsGapRow()
Appends a row that is the default gap for unrelated components.


add

public final java.awt.Component add(java.awt.Component component,
                                    CellConstraints cellConstraints)
Adds a component to the panel using the given cell constraints.

Parameters:
component - the component to add
cellConstraints - the component's cell constraints
Returns:
the added component

add

public final java.awt.Component add(java.awt.Component component,
                                    java.lang.String encodedCellConstraints)
Adds a component to the panel using the given encoded cell constraints.

Parameters:
component - the component to add
encodedCellConstraints - the component's encoded cell constraints
Returns:
the added component

add

public final java.awt.Component add(java.awt.Component component)
Adds a component to the container using the default cell constraints.

Parameters:
component - the component to add
Returns:
the added component