All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class tea.set.Form

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----tea.set.Grid
                                   |
                                   +----tea.set.TextGrid
                                           |
                                           +----tea.set.Form

public class Form
extends TextGrid
Form widget is a specialized TextGrid. It provides a form like layout. A form is consisted of a number of fields. Each field has a field label and a field display/edit area. Form widget layout the fields automatically in either row major or column major order. By default, the field display/edit area will be the same as in TextGrid. However, if a TextField or TextArea is desired, user can set TEXT_FIELD option to force the creation of TextField/TextArea for the field edit area.

Form supports the following properties in addition to the properties inherited from Grid and TextGrid:
Property NameProperty TypeDescription
RowColCountint Row (Column major) or column count (Row major) depending on the layout policy.
FieldString (Indexed) Form field names.
ObjectObject (Indexed) Field value.
Columnsint (Indexed) Field edit area size in characters.
FieldCountint (Readonly) Number of fields.
PositionPoint (Indexed, Readonly) Row and column position of the field in the grid.
Styleint Style flag, EDIT_LINE or TEXT_FIELD.
LayoutPolicyint Layout policy, ROW_MAJOR or COL_MAJOR.
LabelAlignmentint Field label alignment flag, same values as in Grid. Default to Grid.H_RIGHT | Grid.V_CENTER.
TextAlignmentint Field text alignment flag, same values as in Grid. Default to Grid.H_LEFT | Grid.V_CENTER.
Form generates the following events.
Event TypeEvent IDGenerated Description
ObjActionEventActionEvent.ACTION_PERFORMED Text cell content changed (exclude setObject()). ActionEvent.getActionCommand() is the new text. ObjActionEvent.getObject() points to an Integer, which is the field index of the field where the action happened. If the action does not happen in an field, the object points to a Point, where the Point.x is the column number of the modified cell, and Point.y is the row number of the modified cell.

See Also:
TextGrid, Grid

Variable Index

 o COL_MAJOR
Layout fields in column major order.
 o EDIT_LINE
Default TextGrid style display/edit.
 o ROW_MAJOR
Layout fields in row major order.
 o TEXT_FIELD
Explicit TextField/TextArea for each field.

Constructor Index

 o Form()
Create an empty form.

Method Index

 o getCell(int)
Get the component of the specified field.
 o getColumns(int)
Get the char size of the specified field.
 o getField()
Get the field names.
 o getField(int)
Get the field name of the specified field.
 o getFieldCount()
Get the number of fields.
 o getLabelAlignment()
Get the field label alignment option.
 o getLayoutPolicy()
Get the layout policy.
 o getLocation(int)
Get the location of the specified field in the form.
 o getObject(int)
Get the value of the specified field.
 o getPosition(int)
Get the (col, row) of the specified field in the grid.
 o getRowColCount()
Get the number of rows or columns.
 o getStyle()
Get the edit style flag.
 o getTextAlignment()
Get the field text alignment option.
 o layoutForm()
Layout the form fields.
 o processActionEvent(ActionEvent)
Process and dispatch action event.
 o setCell(int, Component)
Set the component of the specified field.
 o setColumns(int, int)
Set the size of the specified field.
 o setColumns(int[])
Set the sizes of the fields.
 o setField(String[])
Set the fields in the form.
 o setLabelAlignment(int)
Set the field label alignment option.
 o setLayoutPolicy(int)
Set the layout policy, either row major or column major.
 o setObject(int, Object)
Set the value of the specified field.
 o setRowColCount(int)
Set the number of row(COL_MAJOR) or number of column(ROW_MAJOR).
 o setStyle(int)
Set the style of text edit, EDIT_LINE or TEXT_FIELD.
 o setTextAlignment(int)
Set the field text alignment option.

Variables

 o ROW_MAJOR
 public static final int ROW_MAJOR
Layout fields in row major order.

 o COL_MAJOR
 public static final int COL_MAJOR
Layout fields in column major order.

 o EDIT_LINE
 public static final int EDIT_LINE
Default TextGrid style display/edit.

 o TEXT_FIELD
 public static final int TEXT_FIELD
Explicit TextField/TextArea for each field.

Constructors

 o Form
 public Form()
Create an empty form.

Methods

 o setRowColCount
 public synchronized void setRowColCount(int num)
Set the number of row(COL_MAJOR) or number of column(ROW_MAJOR).

Parameters:
num - number of row or column.
 o getRowColCount
 public int getRowColCount()
Get the number of rows or columns.

Returns:
number of row/column.
 o getPosition
 public Point getPosition(int idx)
Get the (col, row) of the specified field in the grid.

Parameters:
idx - field index.
Returns:
field position.
 o setField
 public synchronized void setField(String fields[])
Set the fields in the form. This clears the field size information.

Parameters:
fields - field names.
 o getField
 public String[] getField()
Get the field names.

Returns:
field names.
 o getField
 public String getField(int idx)
Get the field name of the specified field.

Parameters:
idx - field index.
Returns:
field name.
 o setCell
 public void setCell(int idx,
                     Component val)
Set the component of the specified field. This method should be called after the form is completely layed out. Otherwise the component will be overriden by the form automatic layout.

Parameters:
idx - field index.
val - field component.
 o getCell
 public Component getCell(int idx)
Get the component of the specified field.

Parameters:
idx - field index.
Returns:
field value.
 o setObject
 public void setObject(int idx,
                       Object val)
Set the value of the specified field.

Parameters:
idx - field index.
val - field value.
 o getObject
 public Object getObject(int idx)
Get the value of the specified field.

Parameters:
idx - field index.
Returns:
field value.
 o setColumns
 public synchronized void setColumns(int cs[])
Set the sizes of the fields. If the size array is shorter than the number of fields, the remaining fields sizes are not changed. !!!setColumns() should be called after setFields(). Otherwise the size information will be cleared by setField.

Parameters:
cs - field sizes.
 o setColumns
 public synchronized void setColumns(int idx,
                                     int sz)
Set the size of the specified field.

Parameters:
idx - field index.
sz - field size.
 o getColumns
 public int getColumns(int idx)
Get the char size of the specified field.

Returns:
field size.
 o getFieldCount
 public int getFieldCount()
Get the number of fields.

Returns:
number of fields.
 o setStyle
 public synchronized void setStyle(int style)
Set the style of text edit, EDIT_LINE or TEXT_FIELD.

Parameters:
style - edit style.
 o getStyle
 public int getStyle()
Get the edit style flag.

Returns:
edit style flag.
 o setLayoutPolicy
 public synchronized void setLayoutPolicy(int policy)
Set the layout policy, either row major or column major.

Parameters:
policy - layout policy.
 o getLayoutPolicy
 public int getLayoutPolicy()
Get the layout policy.

Returns:
layout policy.
 o setLabelAlignment
 public synchronized void setLabelAlignment(int align)
Set the field label alignment option. Use the same alignment flags as Grid.

Parameters:
align - alignment flag.
 o getLabelAlignment
 public int getLabelAlignment()
Get the field label alignment option.

Returns:
alignment flag.
 o setTextAlignment
 public synchronized void setTextAlignment(int align)
Set the field text alignment option. Use the same alignment flags as Grid.

Parameters:
align - alignment flag.
 o getTextAlignment
 public int getTextAlignment()
Get the field text alignment option.

Returns:
alignment flag.
 o getLocation
 public Point getLocation(int idx)
Get the location of the specified field in the form. The location is the location of the edit portion of the field in the grid.

Parameters:
idx - field index.
Returns:
field location.
 o processActionEvent
 public void processActionEvent(ActionEvent e)
Process and dispatch action event.

Parameters:
e - action event.
Overrides:
processActionEvent in class TextGrid
 o layoutForm
 protected synchronized void layoutForm()
Layout the form fields.


All Packages  Class Hierarchy  This Package  Previous  Next  Index