All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class tea.set.TextCell

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

public class TextCell
extends Panel
implements TextEdit
TextCell handle displaying and editing of text. It automatically detects multi-line text and set size accordingly. If TextCell is editable and it's a single line text, tea.set.Cell is used for editing. If it's a multi-line text, java.awt.TextArea is used for editing.

TextCell supports the following properties:
Property NameProperty TypeDescription
InsertModeboolean Text insert (overwrite) mode.
TextString Current text.
SelectedTextString (Readonly) Selected text string.
Editableboolean Editable flag.
SelectionStartint (Readonly) Starting index of select substring.
SelectionEndint (Readonly) Ending index of selected substring.
Columnsint (Readonly) Width in characters.
CursorPosint Cursor position.

See Also:
TextEdit, Cell

Constructor Index

 o TextCell()
Construct an empty editable TextCell.
 o TextCell(int, int, boolean)
Construct a TextCell.
 o TextCell(String, boolean)
Construct a TextCell.

Method Index

 o append(String)
Append text to the end.
 o clearSelection()
Clear selection.
 o getColumns()
Get the number of columns in the TextCell.
 o getCursorPos()
Get cursor position.
 o getGridCol()
Return the grid column number.
 o getGridRow()
Return the grid row number.
 o getSelectedText()
Return selected (highlighted) text.
 o getSelectionEnd()
Get the end position of selection.
 o getSelectionStart()
Get the starting position of selection.
 o getText()
Get text value.
 o insert(String, int)
Insert text at the position.
 o isEditable()
Return true if editable (default).
 o remove(int, int)
Remove text in the range.
 o select(int, int)
Select the text in the range.
 o selectAll()
Select all text.
 o setColumns(int)
Set the number of columns in the TextCell.
 o setCursorPos(int)
Set cursor at position.
 o setEditable(boolean)
Set editable to true of false.
 o setEditMode(boolean)
Switch to editing mode if true, to displaying mode if false.
 o setGrid(int, int)
Set the grid row and column.
 o setInsertMode(boolean)
Set insertion mode to true or false (overwrite).
 o setText(String)
Set the value of text.

Constructors

 o TextCell
 public TextCell()
Construct an empty editable TextCell.

 o TextCell
 public TextCell(int r,
                 int c,
                 boolean editable)
Construct a TextCell. The initial state is display only. It switches to edit mode at mouse click.

Parameters:
r - number of rows.
c - number of columns.
editable - cell editable flag.
 o TextCell
 public TextCell(String text,
                 boolean editable)
Construct a TextCell. The numbers of rows and columns are calculated using the string parameter. The initial state is display only. It switchs to edit mode at mouse click.

Parameters:
text - initial text.
editable - cell editable flag.

Methods

 o setColumns
 public synchronized void setColumns(int columns)
Set the number of columns in the TextCell.

Parameters:
columns - number of columns.
 o getColumns
 public int getColumns()
Get the number of columns in the TextCell.

Returns:
number of columns.
 o setGrid
 public void setGrid(int row,
                     int col)
Set the grid row and column.

 o getGridRow
 public int getGridRow()
Return the grid row number.

Returns:
row number in a grid.
 o getGridCol
 public int getGridCol()
Return the grid column number.

Returns:
column number in a grid.
 o setEditMode
 public void setEditMode(boolean t)
Switch to editing mode if true, to displaying mode if false.

Parameters:
t - edit mode flag.
 o setInsertMode
 public void setInsertMode(boolean mode)
Set insertion mode to true or false (overwrite).

Parameters:
true - for insert mode and false for overwrite mode.
 o setText
 public void setText(String t)
Set the value of text.

Parameters:
t - cell text.
 o getText
 public String getText()
Get text value.

Returns:
cell text.
 o getSelectedText
 public String getSelectedText()
Return selected (highlighted) text.

Returns:
selected text.
 o isEditable
 public boolean isEditable()
Return true if editable (default).

Returns:
true if cell is editable.
 o setEditable
 public void setEditable(boolean t)
Set editable to true of false.

Parameters:
t - cell editable to true or false.
 o getSelectionStart
 public int getSelectionStart()
Get the starting position of selection.

Returns:
starting position of selected text.
 o getSelectionEnd
 public int getSelectionEnd()
Get the end position of selection.

Returns:
ending position of selected text.
 o select
 public void select(int selStart,
                    int selEnd)
Select the text in the range.

Parameters:
selStart - starting position of selection.
selEnd - ending position of selection.
 o selectAll
 public void selectAll()
Select all text.

 o clearSelection
 public void clearSelection()
Clear selection.

 o append
 public void append(String str)
Append text to the end.

Parameters:
str - text to append to cell.
 o insert
 public void insert(String str,
                    int pos)
Insert text at the position.

Parameters:
str - text to insert.
pos - insertion position.
 o setCursorPos
 public void setCursorPos(int pos)
Set cursor at position.

Parameters:
pos - cursor position.
 o getCursorPos
 public int getCursorPos()
Get cursor position.

Returns:
cursor position.
 o remove
 public void remove(int start,
                    int end)
Remove text in the range.

Parameters:
start - starting position of text to remove.
end - ending position of text to remove.

All Packages  Class Hierarchy  This Package  Previous  Next  Index