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 Name | Property Type | Description |
InsertMode | boolean |
True for insert mode, and false for overwrite mode. |
Text | String |
Text in the cell. |
SelectedText | String (Readonly) |
Selected (highlighted) Text in the cell. |
Editable | boolean |
Allow editing or not. |
SelectionStart | int (Readonly) |
Starting index of selected text. |
SelectionEnd | int (Readonly) |
End index of selected text. |
Columns | int |
Text columns in the cell. |
CursorPos | int |
Cursor position in the cell. |
Template | String |
Editing template for the cell. |
Cell generates the following events:
Event Type | Event ID | Generated |
Description |
ActionEvent | ActionEvent.ACTION_PERFORMED |
Return or Tab key, or text changed through setText(). |
ActionEvent.getActionCommand() contains the text. |
TextEvent | TextEvent.TEXT_VALUE_CHANGED |
Text changed by user. |
Generated for every key stroke. |
- See Also:
- TextEdit
-
eventMgr
- EventMgr object handles added event processing and dispatching.
-
Cell()
- Default constructor.
-
Cell(int)
- Construct a Cell with w charactor width.
-
Cell(String)
- Construct a Cell with default string s and width equals s.length().
-
Cell(String, int)
- Construct a Cell with default string s and width equals w.
-
addActionListener(ActionListener)
- Add an action listener.
-
addTextListener(TextListener)
- Add a text listener.
-
append(String)
- Append text to the end.
-
clearSelection()
- Clear selection.
-
getColumns()
- Get number of columns.
-
getCursorPos()
- Get cursor position.
-
getMinimumSize()
- Return the minimum size.
-
getPreferredSize()
- Return the preferred size.
-
getSelectedText()
- Return selected (highlighted) text.
-
getSelectionEnd()
- Get the end position of selection.
-
getSelectionStart()
- Get the starting position of selection.
-
getSize()
- Return the size of the widget.
-
getText()
- Get string value.
-
insert(String, int)
- Insert text at the position.
-
isEditable()
- Return true if editable (default).
-
isInsertMode()
- Get the insertion mode flag.
-
paint(Graphics)
- Paint widget.
-
processActionEvent(ActionEvent)
- Process and dispatch action event.
-
processEvent(AWTEvent)
- Process and dispatch event.
-
processFocusEvent(FocusEvent)
- Called when this component got focus.
-
processKeyEvent(KeyEvent)
- Handle keydown event.
-
processMouseEvent(MouseEvent)
- Handle mouse down event.
-
processMouseMotionEvent(MouseEvent)
- Handle mouse draw event.
-
processTextEvent(TextEvent)
- Process and dispatch text event.
-
remove(int, int)
- Remove text in the range.
-
removeActionListener(ActionListener)
- Remove an action listener.
-
removeTextListener(TextListener)
- Remove a text listener.
-
requestFocus()
- Override requestFocus to set focus to true, needed when already has
focus.
-
select(int, int)
- Select the text in the range.
-
selectAll()
- Select all text.
-
setColumns(int)
- Sets the number of columns in this TextEdit.
-
setCursorPos(int)
- Set cursor at position.
-
setEditable(boolean)
- Set editable to true or false.
-
setInsertMode(boolean)
- Set insertion mode to true or false.
-
setTemplate(String)
- Set the template string, used to set size.
-
setText(String)
- Set the value of cell.
-
tabbable()
- Allow tab to shift focus to this component.
eventMgr
protected EventMgr eventMgr
- EventMgr object handles added event processing and dispatching.
Cell
public Cell()
- Default constructor. Create a Cell with width equals to 5.
Cell
public Cell(int w)
- Construct a Cell with w charactor width. The cell is initially
empty.
- Parameters:
- w - number of columns in cell.
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.
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.
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.
isInsertMode
public boolean isInsertMode()
- Get the insertion mode flag.
- Returns:
- true if it is in insert mode.
getSize
public Dimension getSize()
- Return the size of the widget.
- Returns:
- size of cell.
- Overrides:
- getSize in class Component
getMinimumSize
public Dimension getMinimumSize()
- Return the minimum size. Calculated using font metrics.
- Returns:
- minimum size of cell.
- Overrides:
- getMinimumSize in class Component
getPreferredSize
public Dimension getPreferredSize()
- Return the preferred size.
- Returns:
- preferred size of cell.
- Overrides:
- getPreferredSize in class Component
setText
public synchronized void setText(String t)
- Set the value of cell.
- Parameters:
- t - cell text.
getText
public String getText()
- Get string value.
- Returns:
- cell text.
getSelectedText
public String getSelectedText()
- Return selected (highlighted) text.
- Returns:
- selected text.
isEditable
public boolean isEditable()
- Return true if editable (default).
- Returns:
- true if cell is editable.
setEditable
public synchronized void setEditable(boolean t)
- Set editable to true or false.
- Parameters:
- t - cell editable to true or false.
getSelectionStart
public int getSelectionStart()
- Get the starting position of selection.
- Returns:
- starting position of selected text.
getSelectionEnd
public int getSelectionEnd()
- Get the end position of selection.
- Returns:
- ending position of selected text.
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.
selectAll
public synchronized void selectAll()
- Select all text.
clearSelection
public synchronized void clearSelection()
- Clear selection.
getColumns
public int getColumns()
- Get number of columns.
- Returns:
- number of columns in cell.
setColumns
public synchronized void setColumns(int w)
- Sets the number of columns in this TextEdit.
- Parameters:
- columns - the number of columns
append
public void append(String str)
- Append text to the end.
- Parameters:
- str - text to append to cell.
insert
public void insert(String str,
int pos)
- Insert text at the position.
- Parameters:
- str - text to insert.
- pos - insertion position.
setCursorPos
public synchronized void setCursorPos(int pos)
- Set cursor at position.
- Parameters:
- pos - cursor position.
getCursorPos
public int getCursorPos()
- Get cursor position.
- Returns:
- cursor position.
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.
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).
processKeyEvent
public void processKeyEvent(KeyEvent e)
- Handle keydown event.
- Parameters:
- e - event object.
- key - key pressed.
- Returns:
- false.
- Overrides:
- processKeyEvent in class Component
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
addActionListener
public void addActionListener(ActionListener listener)
- Add an action listener.
- Parameters:
- listener - action listener.
addTextListener
public void addTextListener(TextListener listener)
- Add a text listener.
- Parameters:
- listener - text listener.
removeActionListener
public void removeActionListener(ActionListener listener)
- Remove an action listener.
- Parameters:
- listener - action listener.
removeTextListener
public void removeTextListener(TextListener listener)
- Remove a text listener.
- Parameters:
- listener - text listener.
processEvent
public void processEvent(AWTEvent e)
- Process and dispatch event.
- Parameters:
- e - event object.
- Overrides:
- processEvent in class Component
processActionEvent
public void processActionEvent(ActionEvent e)
- Process and dispatch action event.
- Parameters:
- e - action event.
processTextEvent
public void processTextEvent(TextEvent e)
- Process and dispatch text event.
- Parameters:
- e - text event.
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
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
requestFocus
public void requestFocus()
- Override requestFocus to set focus to true, needed when already has
focus.
- Overrides:
- requestFocus in class Component
paint
public void paint(Graphics g)
- Paint widget.
- Parameters:
- g - Graphics content of this component.
- Overrides:
- paint in class Canvas
tabbable
public boolean tabbable()
- Allow tab to shift focus to this component.
- Returns:
- true.
All Packages Class Hierarchy This Package Previous Next Index