Class tea.set.TextGrid
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class tea.set.TextGrid

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

public class TextGrid
extends Grid
The TextGrid widget is a specialized version Grid widget. All cells of the grid can be initialized to TextCell or TextCanvas at construction time. Or you can import a text delimited file from an URL and have a table created automatially. Alternatively, you can choose a constructor to create an empty TextGrid, and simply use it as an enhanced Grid widget. Convenient methods are provided to get and set text values of each cell.

When cells are populated from the constructor or set using TextGrid.setObject, TextCells are created for each cell if TextGrid is editable, or TextCanvas are created if it's not editable. TextGrid.setObject() also supports many other types of cell components using text encoding.

If a TextGrid is row selectable, a single mouse click inside a cell selects a row. If the TextGrid is not row selectable but is column selectable, a single mouse click inside a cell selects a column.

See Also:
Grid, TextCell, TextCanvas, TextEdit, Cell

Constructor Index

 o TextGrid(InputStream, String, boolean)
Construct a text grid from a file.
 o TextGrid(int, int)
Construct an empty text grid.
 o TextGrid(int, int, boolean)
Construct an empty text grid.
 o TextGrid(int, int, int, int, boolean)
Construct a textgrid widget with row rows, col columns, and w characters in each column.
 o TextGrid(int, int, int[], int[], boolean)
Construct a textgrid widget with row rows, col columns, and character width for each column coresponds to the value in cwidth.

Method Index

 o getObject(int, int)
Return the object in cell (r, c).
 o handleEvent(Event)
Handle focus and row selection.
 o setCol(int, String, String)
Set a grid column from a delimited field string.
 o setObject(int, int, Object)
Set the text in cell (r, c) to object.
 o setRow(int, String, String)
Set a grid row from a delimited field string.

Constructors

 o TextGrid
  public TextGrid(int row,
                  int col)
Construct an empty text grid. The cells are not initialized. User needs to set cell explicitly. The default is non-editable. This affects subsequent TextGrid.setObject() calls and what type of cell is created for string types.
Parameters:
row - number of rows.
col - number of columns.
 o TextGrid
  public TextGrid(int row,
                  int col,
                  boolean editable)
Construct an empty text grid. The cells are not initialized. User needs to set cell explicitly. The editable flag affects subsequent TextGrid.setObject() calls and what type of cell is created for string types.
Parameters:
row - number of rows.
col - number of columns.
 o TextGrid
  public TextGrid(int row,
                  int col,
                  int w,
                  int h,
                  boolean editable)
Construct a textgrid widget with row rows, col columns, and w characters in each column.
Parameters:
row - number of rows.
col - number of columns.
w - column width in characters.
h - row height in characters.
editable - cell editable flag.
 o TextGrid
  public TextGrid(int row,
                  int col,
                  int cwidth[],
                  int rheight[],
                  boolean editable)
Construct a textgrid widget with row rows, col columns, and character width for each column coresponds to the value in cwidth.
Parameters:
row - number of rows.
col - number of columns.
cwidth - column width array in characters.
rheight - row height array in characters.
editable - cell editable flag.
 o TextGrid
  public TextGrid(InputStream input,
                  String delim,
                  boolean editable)
Construct a text grid from a file. They file should be delimited by the specified delimiter. Each field can contain either a plain text string, or an encoded string in the same format as setObject() method.
Parameters:
input - import source.
delim - column delimiter.
editable - cell editable flag.

Methods

 o getObject
  public Object getObject(int r,
                          int c)
Return the object in cell (r, c). The type of the object depends on the cell type.
TextEdit, TextCanvas, List, Choice, Button, or TextComponent
String - this includes all text cells, List, Choice, label, Button, TextComponent, and spinners.
ImageCanvas
Image.
Checkbox
Boolean - the current state of the checkbox.
Parameters:
r - row number.
c - column number.
Returns:
cell object.
 o setObject
  public void setObject(int r,
                        int c,
                        Object content)
Set the text in cell (r, c) to object. The following object types are supported:
String
the string can either be a plain text string, or an encoded string for other types of object. A plain string cause a tea.set.TextCanvas being created for the cell if this TextGrid is not editable, or a tea.set.TextCell created fro the cell if it is editable. The encoding is as following:
  • <EDIT[:row,col]>string, [row,col] is an optional specification of the number of row and columns of this text cell. If it's not specified, the value is derived from the initial text string. This create an editable TextCell and it overrides the TextGrid editable flag. The string is used to initialize the TextCell.
  • <TEXTFIELD[:col]>string, col is an optional specification of the number of columns of this text field. If it's not specified, the value is derived from the initial text string. This create an editable TextField and it overrides the TextGrid editable flag. The string is used to initialize the TextCell.
  • <TEXTAREA[:row,col]>string, [row,col] is an optional specification of the number of row and columns of this text area. If it's not specified, the value is derived from the initial text string. This create an editable TextArea and it overrides the TextGrid editable flag. The string is used to initialize the TextArea.
  • <LABEL[:row,col]>string, [row,col] is an optional specification of the number of row and columns of this text cell. If it's not specified, the value is derived from the initial text string. This create a TextCanvas and it overrides the TextGrid editable flag. The string is used to initialize the TextCanvas.
  • <BUTTON>label, a Button is created with the string as the button label.
  • <MASK>mask-string, the string value is treated as a edit mask, and a MaskText is created for the cell.
  • <STATE>label, a Checkbox is created with the string as the Checkbox label.
  • <IMAGE>url, the string value is treated as an URL and used to fetch the image data. An ImageCanvas is created for the cell to contain the image.
  • <LIST[:d]>item-list, d is an optional delimiter that can be specified in the list tag. The string is a list of items delimited by the specified delimiter. If no delimiter is specified, the default delimiter is comma. A java.awt.List component is created for the cell.
  • <CHOICE[:d]>item-list, d is an optional delimiter that can be specified in the choice tag. The string is a list of items delimited by the specified delimiter. If no delimiter is specified, the default delimiter is comma. A java.awt.Choice component is created for the cell.
  • <SPIN[:d]>item-list, d is an optional delimiter that can be specified in the choice tag. The string is a list of items delimited by the specified delimiter. If no delimiter is specified, the default delimiter is comma. A tea.set.Spinner component is created for the cell.
  • <RANGE>lower-higher, the lower and higher values of the range will be used to create a numeric spinner.
Image
the image is added to the grid as ImageCanvas.
String[]
a text Spinner is created for the cell with the list of strings.
int[]
the length of the array must equal to 2. A numeric Spinner is created for the cell with int[0] and int[1] as the lower and higher bound values respectively.
Parameters:
r - row number.
c - column number.
content - cell object.
 o setRow
  public void setRow(int r,
                     String str,
                     String delim)
Set a grid row from a delimited field string. This method uses TextGrid.setObject() method to set individual cell by extracting a string representation from the delimited text. This method is different from the Grid.setRow().
Parameters:
r - row number.
str - string containing delimited cell representation.
delim - delimiter string.
 o setCol
  public void setCol(int c,
                     String str,
                     String delim)
Set a grid column from a delimited field string. This method uses TextGrid.setObject() method to set individual cell by extracting a string representation from the delimited text. This method is different from the Grid.setCol().
Parameters:
c - column number.
str - string containing delimited cell representation.
delim - delimiter string.
 o handleEvent
  public boolean handleEvent(Event e)
Handle focus and row selection.
Parameters:
e - event object.
Overrides:
handleEvent in class Grid

All Packages  Class Hierarchy  This Package  Previous  Next  Index