All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class tea.set.Cell

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----tea.set.Cell

public class Cell
extends Canvas
implements TextEdit
Text cell class used by Table, ListText, and MaskText as a more extendable TextField. It provides the basic editing functionality plus cursor and text highlight control.

Cell supports the following properties:
Property NameProperty TypeDescription
InsertModeboolean True for insert mode, and false for overwrite mode.
TextString Text in the cell.
SelectedTextString (Readonly) Selected (highlighted) Text in the cell.
Editableboolean Allow editing or not.
SelectionStartint (Readonly) Starting index of selected text.
SelectionEndint (Readonly) End index of selected text.
Columnsint Text columns in the cell.
CursorPosint Cursor position in the cell.
TemplateString Editing template for the cell.

Cell generates the following events:
Event TypeEvent IDGenerated Description
ActionEventActionEvent.ACTION_PERFORMED Return or Tab key, or text changed through setText(). ActionEvent.getActionCommand() contains the text.
TextEventTextEvent.TEXT_VALUE_CHANGED Text changed by user. Generated for every key stroke.

See Also:
TextEdit

Variable Index

 o eventMgr
EventMgr object handles added event processing and dispatching.

Constructor Index

 o Cell()
Default constructor.
 o Cell(int)
Construct a Cell with w charactor width.
 o Cell(String)
Construct a Cell with default string s and width equals s.length().
 o Cell(String, int)
Construct a Cell with default string s and width equals w.

Method Index

 o addActionListener(ActionListener)
Add an action listener.
 o addTextListener(TextListener)
Add a text listener.
 o append(String)
Append text to the end.
 o clearSelection()
Clear selection.
 o getColumns()
Get number of columns.
 o getCursorPos()
Get cursor position.
 o getMinimumSize()
Return the minimum size.
 o getPreferredSize()
Return the preferred size.
 o getSelectedText()
Return selected (highlighted) text.
 o getSelectionEnd()
Get the end position of selection.
 o getSelectionStart()
Get the starting position of selection.
 o getSize()
Return the size of the widget.
 o getText()
Get string value.
 o insert(String, int)
Insert text at the position.
 o isEditable()
Return true if editable (default).
 o isInsertMode()
Get the insertion mode flag.
 o paint(Graphics)
Paint widget.
 o processActionEvent(ActionEvent)
Process and dispatch action event.
 o processEvent(AWTEvent)
Process and dispatch event.
 o processFocusEvent(FocusEvent)
Called when this component got focus.
 o processKeyEvent(KeyEvent)
Handle keydown event.
 o processMouseEvent(MouseEvent)
Handle mouse down event.
 o processMouseMotionEvent(MouseEvent)
Handle mouse draw event.
 o processTextEvent(TextEvent)
Process and dispatch text event.
 o remove(int, int)
Remove text in the range.
 o removeActionListener(ActionListener)
Remove an action listener.
 o removeTextListener(TextListener)
Remove a text listener.
 o requestFocus()
Override requestFocus to set focus to true, needed when already has focus.
 o select(int, int)
Select the text in the range.
 o selectAll()
Select all text.
 o setColumns(int)
Sets the number of columns in this TextEdit.
 o setCursorPos(int)
Set cursor at position.
 o setEditable(boolean)
Set editable to true or false.
 o setInsertMode(boolean)
Set insertion mode to true or false.
 o setTemplate(String)
Set the template string, used to set size.
 o setText(String)
Set the value of cell.
 o tabbable()
Allow tab to shift focus to this component.

Variables

 o eventMgr
 protected EventMgr eventMgr
EventMgr object handles added event processing and dispatching.

Constructors

 o Cell
 public Cell()
Default constructor. Create a Cell with width equals to 5.

 o Cell
 public Cell(int w)
Construct a Cell with w charactor width. The cell is initially empty.

Parameters:
w - number of columns in cell.
 o Cell
 public Cell(String s)
Construct a Cell with default string s and width equals s.length(). The cell is initialized to the string passed in.

Parameters:
s - initial text.
 o Cell
 public Cell(String s,
             int w)
Construct a Cell with default string s and width equals w.

Parameters:
s - initial text.
w - number of columns.

Methods

 o setInsertMode
 public synchronized void setInsertMode(boolean mode)
Set insertion mode to true or false. If insertion mode is true, new characters typed in by user are inserted at the cursor position. If insertion mode is false, new characters typed in by user replace the existing characters at the cursor position.

Parameters:
true - for insert mode and false for overwrite mode.
 o isInsertMode
 public boolean isInsertMode()
Get the insertion mode flag.

Returns:
true if it is in insert mode.
 o getSize
 public Dimension getSize()
Return the size of the widget.

Returns:
size of cell.
Overrides:
getSize in class Component
 o getMinimumSize
 public Dimension getMinimumSize()
Return the minimum size. Calculated using font metrics.

Returns:
minimum size of cell.
Overrides:
getMinimumSize in class Component
 o getPreferredSize
 public Dimension getPreferredSize()
Return the preferred size.

Returns:
preferred size of cell.
Overrides:
getPreferredSize in class Component
 o setText
 public synchronized void setText(String t)
Set the value of cell.

Parameters:
t - cell text.
 o getText
 public String getText()
Get string 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 synchronized void setEditable(boolean t)
Set editable to true or 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 synchronized 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 synchronized void selectAll()
Select all text.

 o clearSelection
 public synchronized void clearSelection()
Clear selection.

 o getColumns
 public int getColumns()
Get number of columns.

Returns:
number of columns in cell.
 o setColumns
 public synchronized void setColumns(int w)
Sets the number of columns in this TextEdit.

Parameters:
columns - the number of columns
 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 synchronized 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 synchronized 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.
 o setTemplate
 public synchronized void setTemplate(String t)
Set the template string, used to set size. This method is similar to setText(String) for the string is used to calculate the size of the cell, but the template string is not displayed by the cell.

Parameters:
t - text template(mask).
 o processKeyEvent
 public void processKeyEvent(KeyEvent e)
Handle keydown event.

Parameters:
e - event object.
key - key pressed.
Returns:
false.
Overrides:
processKeyEvent in class Component
 o processMouseEvent
 public void processMouseEvent(MouseEvent e)
Handle mouse down event.

Parameters:
e - event object.
x - x coordinate of the mouse click point.
y - y coordinate of the mouse click point.
Returns:
false.
Overrides:
processMouseEvent in class Component
 o addActionListener
 public void addActionListener(ActionListener listener)
Add an action listener.

Parameters:
listener - action listener.
 o addTextListener
 public void addTextListener(TextListener listener)
Add a text listener.

Parameters:
listener - text listener.
 o removeActionListener
 public void removeActionListener(ActionListener listener)
Remove an action listener.

Parameters:
listener - action listener.
 o removeTextListener
 public void removeTextListener(TextListener listener)
Remove a text listener.

Parameters:
listener - text listener.
 o processEvent
 public void processEvent(AWTEvent e)
Process and dispatch event.

Parameters:
e - event object.
Overrides:
processEvent in class Component
 o processActionEvent
 public void processActionEvent(ActionEvent e)
Process and dispatch action event.

Parameters:
e - action event.
 o processTextEvent
 public void processTextEvent(TextEvent e)
Process and dispatch text event.

Parameters:
e - text event.
 o processMouseMotionEvent
 public void processMouseMotionEvent(MouseEvent e)
Handle mouse draw event.

Parameters:
e - event object.
x - x coordinate of the mouse click point.
y - y coordinate of the mouse click point.
Returns:
false.
Overrides:
processMouseMotionEvent in class Component
 o processFocusEvent
 public void processFocusEvent(FocusEvent e)
Called when this component got focus.

Parameters:
e - event object.
o - event argument object.
Returns:
false.
Overrides:
processFocusEvent in class Component
 o requestFocus
 public void requestFocus()
Override requestFocus to set focus to true, needed when already has focus.

Overrides:
requestFocus in class Component
 o paint
 public void paint(Graphics g)
Paint widget.

Parameters:
g - Graphics content of this component.
Overrides:
paint in class Canvas
 o tabbable
 public boolean tabbable()
Allow tab to shift focus to this component.

Returns:
true.

All Packages  Class Hierarchy  This Package  Previous  Next  Index