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 Name | Property Type | Description |
RowColCount | int |
Row (Column major) or column count (Row major) depending on the
layout policy. |
Field | String (Indexed) |
Form field names. |
Object | Object (Indexed) |
Field value. |
Columns | int (Indexed) |
Field edit area size in characters. |
FieldCount | int (Readonly) |
Number of fields. |
Position | Point (Indexed, Readonly) |
Row and column position of the field in the grid. |
Style | int |
Style flag, EDIT_LINE or TEXT_FIELD. |
LayoutPolicy | int |
Layout policy, ROW_MAJOR or COL_MAJOR. |
LabelAlignment | int |
Field label alignment flag, same values as in Grid. Default to
Grid.H_RIGHT | Grid.V_CENTER. |
TextAlignment | int |
Field text alignment flag, same values as in Grid. Default to
Grid.H_LEFT | Grid.V_CENTER. |
Form generates the following events.
Event Type | Event ID | Generated |
Description |
ObjActionEvent | ActionEvent.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
-
COL_MAJOR
- Layout fields in column major order.
-
EDIT_LINE
- Default TextGrid style display/edit.
-
ROW_MAJOR
- Layout fields in row major order.
-
TEXT_FIELD
- Explicit TextField/TextArea for each field.
-
Form()
- Create an empty form.
-
getCell(int)
- Get the component of the specified field.
-
getColumns(int)
- Get the char size of the specified field.
-
getField()
- Get the field names.
-
getField(int)
- Get the field name of the specified field.
-
getFieldCount()
- Get the number of fields.
-
getLabelAlignment()
- Get the field label alignment option.
-
getLayoutPolicy()
- Get the layout policy.
-
getLocation(int)
- Get the location of the specified field in the form.
-
getObject(int)
- Get the value of the specified field.
-
getPosition(int)
- Get the (col, row) of the specified field in the grid.
-
getRowColCount()
- Get the number of rows or columns.
-
getStyle()
- Get the edit style flag.
-
getTextAlignment()
- Get the field text alignment option.
-
layoutForm()
- Layout the form fields.
-
processActionEvent(ActionEvent)
- Process and dispatch action event.
-
setCell(int, Component)
- Set the component of the specified field.
-
setColumns(int, int)
- Set the size of the specified field.
-
setColumns(int[])
- Set the sizes of the fields.
-
setField(String[])
- Set the fields in the form.
-
setLabelAlignment(int)
- Set the field label alignment option.
-
setLayoutPolicy(int)
- Set the layout policy, either row major or column major.
-
setObject(int, Object)
- Set the value of the specified field.
-
setRowColCount(int)
- Set the number of row(COL_MAJOR) or number of column(ROW_MAJOR).
-
setStyle(int)
- Set the style of text edit, EDIT_LINE or TEXT_FIELD.
-
setTextAlignment(int)
- Set the field text alignment option.
ROW_MAJOR
public static final int ROW_MAJOR
- Layout fields in row major order.
COL_MAJOR
public static final int COL_MAJOR
- Layout fields in column major order.
EDIT_LINE
public static final int EDIT_LINE
- Default TextGrid style display/edit.
TEXT_FIELD
public static final int TEXT_FIELD
- Explicit TextField/TextArea for each field.
Form
public Form()
- Create an empty form.
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.
getRowColCount
public int getRowColCount()
- Get the number of rows or columns.
- Returns:
- number of row/column.
getPosition
public Point getPosition(int idx)
- Get the (col, row) of the specified field in the grid.
- Parameters:
- idx - field index.
- Returns:
- field position.
setField
public synchronized void setField(String fields[])
- Set the fields in the form. This clears the field size information.
- Parameters:
- fields - field names.
getField
public String[] getField()
- Get the field names.
- Returns:
- field names.
getField
public String getField(int idx)
- Get the field name of the specified field.
- Parameters:
- idx - field index.
- Returns:
- field name.
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.
getCell
public Component getCell(int idx)
- Get the component of the specified field.
- Parameters:
- idx - field index.
- Returns:
- field value.
setObject
public void setObject(int idx,
Object val)
- Set the value of the specified field.
- Parameters:
- idx - field index.
- val - field value.
getObject
public Object getObject(int idx)
- Get the value of the specified field.
- Parameters:
- idx - field index.
- Returns:
- field value.
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.
setColumns
public synchronized void setColumns(int idx,
int sz)
- Set the size of the specified field.
- Parameters:
- idx - field index.
- sz - field size.
getColumns
public int getColumns(int idx)
- Get the char size of the specified field.
- Returns:
- field size.
getFieldCount
public int getFieldCount()
- Get the number of fields.
- Returns:
- number of fields.
setStyle
public synchronized void setStyle(int style)
- Set the style of text edit, EDIT_LINE or TEXT_FIELD.
- Parameters:
- style - edit style.
getStyle
public int getStyle()
- Get the edit style flag.
- Returns:
- edit style flag.
setLayoutPolicy
public synchronized void setLayoutPolicy(int policy)
- Set the layout policy, either row major or column major.
- Parameters:
- policy - layout policy.
getLayoutPolicy
public int getLayoutPolicy()
- Get the layout policy.
- Returns:
- layout policy.
setLabelAlignment
public synchronized void setLabelAlignment(int align)
- Set the field label alignment option. Use the same alignment flags
as Grid.
- Parameters:
- align - alignment flag.
getLabelAlignment
public int getLabelAlignment()
- Get the field label alignment option.
- Returns:
- alignment flag.
setTextAlignment
public synchronized void setTextAlignment(int align)
- Set the field text alignment option. Use the same alignment flags
as Grid.
- Parameters:
- align - alignment flag.
getTextAlignment
public int getTextAlignment()
- Get the field text alignment option.
- Returns:
- alignment flag.
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.
processActionEvent
public void processActionEvent(ActionEvent e)
- Process and dispatch action event.
- Parameters:
- e - action event.
- Overrides:
- processActionEvent in class TextGrid
layoutForm
protected synchronized void layoutForm()
- Layout the form fields.
All Packages Class Hierarchy This Package Previous Next Index