org.springframework.richclient.layout
Class TableLayoutBuilder

java.lang.Object
  extended by org.springframework.richclient.layout.TableLayoutBuilder
All Implemented Interfaces:
LayoutBuilder

public class TableLayoutBuilder
extends Object
implements LayoutBuilder

A panel builder that provides the capability to quickly build grid based forms. The builder allows for layout to be defined in a way that will be familiar to anyone used to HTML tables and JGoodies Forms. Key features:

Example:
 TableLayoutBuilder table = new TableLayoutBuilder();
 table
  .row()
      .separator("General 1")
  .row()
      .cell(new JLabel("Company"), "colSpec=right:pref colGrId=labels")
      .labelGapCol()
      .cell(new JFormattedTextField())
  .row()
      .cell(new JLabel("Contact"))
      .cell(new JFormattedTextField())
      .unrelatedGapRow()
      .separator("Propeller")
  .row()
      .cell(new JLabel("PTI [kW]")).cell(new JFormattedTextField())
      .unrelatedGapCol()
      .cell(new JLabel("Description"), "colSpec=right:pref colGrId=labels")
      .labelGapCol()
      .cell(new JScrollPane(new JTextArea()), "rowspan=3")
  .row()
      .cell(new JLabel("R [mm]"))
      .cell(new JFormattedTextField())
      .cell()
  .row()
      .cell(new JLabel("D [mm]"))
      .cell(new JFormattedTextField())
      .cell(); 
 table.getPanel();
 

Author:
oliverh

Field Summary
static String ALIGN
           
static String COLGROUPID
           
static String COLSPAN
           
static String COLSPEC
           
static int COLUMN_MAJOR_FOCUS_ORDER
          Constant indicating column major focus traversal order.
static String DEFAULT_LABEL_ATTRIBUTES
           
static int ROW_MAJOR_FOCUS_ORDER
          Constant indicating row major focus traversal order.
static String ROWGROUPID
           
static String ROWSPAN
           
static String ROWSPEC
           
static String VALIGN
           
 
Constructor Summary
TableLayoutBuilder()
          Creates a new TableLayoutBuilder.
TableLayoutBuilder(JPanel panel)
          Creates a new TableLayoutBuilder which will perform it's layout in the supplied JPanel.
 
Method Summary
 TableLayoutBuilder cell()
          Inserts an empty cell at the current row/column.
 TableLayoutBuilder cell(JComponent component)
          Inserts a component at the current row/column.
 TableLayoutBuilder cell(JComponent component, String attributes)
          Inserts a component at the current row/column.
 TableLayoutBuilder cell(String attributes)
          Inserts an empty cell at the current row/column.
 TableLayoutBuilder gapCol()
          Inserts a related component gap column.
 TableLayoutBuilder gapCol(com.jgoodies.forms.layout.ColumnSpec colSpec)
          Inserts a gap column with the specified colSpec.
 TableLayoutBuilder gapCol(String colSpec)
          Inserts a gap column with the specified colSpec.
 ComponentFactory getComponentFactory()
          Returns the ComponentFactorythat this uses to create things like labels.
 int getCurrentCol()
          Returns the current column (zero-based) that the builder is putting components in.
 int getCurrentRow()
          Returns the current row (zero-based) that the builder is putting components in.
 JPanel getPanel()
          Creates and returns a JPanel with all the given components in it, using the "hints" that were provided to the builder.
 boolean hasGapAbove()
          Return true if there is a gap row above of the current cell
 boolean hasGapToLeft()
          Return true if there is a gap column to the left of the current cell
protected  void installFocusOrder(List focusOrder)
          Install the specified focus order.
 TableLayoutBuilder labelGapCol()
          Inserts a label component gap column.
 TableLayoutBuilder relatedGapRow()
          Inserts a new row.
 TableLayoutBuilder row()
          Inserts a new row.
 TableLayoutBuilder row(com.jgoodies.forms.layout.RowSpec gapRowSpec)
          Inserts a new row.
 TableLayoutBuilder row(String gapRowSpec)
          Inserts a new row.
 TableLayoutBuilder separator(String labelKey)
          Inserts a separator with the given label.
 TableLayoutBuilder separator(String labelKey, String attributes)
          Inserts a separator with the given label.
 void setComponentFactory(ComponentFactory componentFactory)
          Sets the ComponentFactorythat this uses to create things like labels.
 void setCustomFocusTraversalOrder(List focusOrder)
          Set a custom focus traversal order using the provided list of components.
 void setFocusTraversalOrder(int traversalOrder)
          Set the focus traversal order.
 TableLayoutBuilder unrelatedGapCol()
          Inserts a unrelated component gap column.
 TableLayoutBuilder unrelatedGapRow()
          Inserts a new row.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_LABEL_ATTRIBUTES

public static final String DEFAULT_LABEL_ATTRIBUTES
See Also:
Constant Field Values

ALIGN

public static final String ALIGN
See Also:
Constant Field Values

VALIGN

public static final String VALIGN
See Also:
Constant Field Values

ROWSPEC

public static final String ROWSPEC
See Also:
Constant Field Values

COLSPEC

public static final String COLSPEC
See Also:
Constant Field Values

ROWSPAN

public static final String ROWSPAN
See Also:
Constant Field Values

COLSPAN

public static final String COLSPAN
See Also:
Constant Field Values

ROWGROUPID

public static final String ROWGROUPID
See Also:
Constant Field Values

COLGROUPID

public static final String COLGROUPID
See Also:
Constant Field Values

COLUMN_MAJOR_FOCUS_ORDER

public static final int COLUMN_MAJOR_FOCUS_ORDER
Constant indicating column major focus traversal order.

See Also:
Constant Field Values

ROW_MAJOR_FOCUS_ORDER

public static final int ROW_MAJOR_FOCUS_ORDER
Constant indicating row major focus traversal order.

See Also:
Constant Field Values
Constructor Detail

TableLayoutBuilder

public TableLayoutBuilder()
Creates a new TableLayoutBuilder.


TableLayoutBuilder

public TableLayoutBuilder(JPanel panel)
Creates a new TableLayoutBuilder which will perform it's layout in the supplied JPanel. Note that any components that are already contained by the panel will be removed.

Method Detail

getComponentFactory

public ComponentFactory getComponentFactory()
Returns the ComponentFactorythat this uses to create things like labels.

Returns:
if not explicitly set, this uses the Application's

setComponentFactory

public void setComponentFactory(ComponentFactory componentFactory)
Sets the ComponentFactorythat this uses to create things like labels.


getCurrentRow

public int getCurrentRow()
Returns the current row (zero-based) that the builder is putting components in.


getCurrentCol

public int getCurrentCol()
Returns the current column (zero-based) that the builder is putting components in.


row

public TableLayoutBuilder row()
Inserts a new row. No gap row is inserted before this row.


row

public TableLayoutBuilder row(String gapRowSpec)
Inserts a new row. A gap row with specified RowSpec will be inserted before this row.


row

public TableLayoutBuilder row(com.jgoodies.forms.layout.RowSpec gapRowSpec)
Inserts a new row. A gap row with specified RowSpec will be inserted before this row.


relatedGapRow

public TableLayoutBuilder relatedGapRow()
Inserts a new row. A related component gap row will be inserted before this row.


unrelatedGapRow

public TableLayoutBuilder unrelatedGapRow()
Inserts a new row. An unrelated component gap row will be inserted before this row.


cell

public TableLayoutBuilder cell()
Inserts an empty cell at the current row/column.


cell

public TableLayoutBuilder cell(String attributes)
Inserts an empty cell at the current row/column. Attributes may be zero or more of rowSpec, columnSpec, colGrId and rowGrId.


cell

public TableLayoutBuilder cell(JComponent component)
Inserts a component at the current row/column.


cell

public TableLayoutBuilder cell(JComponent component,
                               String attributes)
Inserts a component at the current row/column. Attributes may be zero or more of rowSpec, columnSpec, colGrId, rowGrId, align and valign.


gapCol

public TableLayoutBuilder gapCol()
Inserts a related component gap column.


gapCol

public TableLayoutBuilder gapCol(String colSpec)
Inserts a gap column with the specified colSpec.


gapCol

public TableLayoutBuilder gapCol(com.jgoodies.forms.layout.ColumnSpec colSpec)
Inserts a gap column with the specified colSpec.


labelGapCol

public TableLayoutBuilder labelGapCol()
Inserts a label component gap column.


unrelatedGapCol

public TableLayoutBuilder unrelatedGapCol()
Inserts a unrelated component gap column.


separator

public TableLayoutBuilder separator(String labelKey)
Inserts a separator with the given label.


separator

public TableLayoutBuilder separator(String labelKey,
                                    String attributes)
Inserts a separator with the given label. Attributes my be zero or more of rowSpec, columnSpec, colGrId, rowGrId, align and valign.


hasGapToLeft

public boolean hasGapToLeft()
Return true if there is a gap column to the left of the current cell


hasGapAbove

public boolean hasGapAbove()
Return true if there is a gap row above of the current cell


getPanel

public JPanel getPanel()
Creates and returns a JPanel with all the given components in it, using the "hints" that were provided to the builder.

Specified by:
getPanel in interface LayoutBuilder
Returns:
a new JPanel with the components laid-out in it

setFocusTraversalOrder

public void setFocusTraversalOrder(int traversalOrder)
Set the focus traversal order.

Parameters:
order - forcus traversal order. Must be one of COLUMN_MAJOR_FOCUS_ORDER or ROW_MAJOR_FOCUS_ORDER.

setCustomFocusTraversalOrder

public void setCustomFocusTraversalOrder(List focusOrder)
Set a custom focus traversal order using the provided list of components.

Parameters:
focusOrder - List of components in the order that focus should follow.

installFocusOrder

protected void installFocusOrder(List focusOrder)
Install the specified focus order.

Parameters:
focusOrder - List of components in the order that focus should follow.


Copyright © 2004-2008 The Spring Framework. All Rights Reserved.