Class tea.set.Cell
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.
See Also:
TextEdit

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 appendText(String)
Append text to the end.
 o clearSelection()
Clear selection.
 o getColumns()
Get number of columns.
 o getCursorPos()
Get cursor position.
 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 string value.
 o gotFocus(Event, Object)
Called when this component got focus.
 o insertText(String, int)
Insert text at the position.
 o isEditable()
Return true if editable (default).
 o keyDown(Event, int)
Handle keydown event.
 o lostFocus(Event, Object)
Called when this component lost focus.
 o minimumSize()
Return the minimum size.
 o mouseDown(Event, int, int)
Handle mouse down event.
 o mouseDrag(Event, int, int)
Handle mouse draw event.
 o mouseUp(Event, int, int)
Handle mouse up event.
 o paint(Graphics)
Paint widget.
 o preferredSize()
Return the preferred size.
 o removeText(int, int)
Remove text in the range.
 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 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 size()
Return the size of the widget.
 o tabbable()
Allow tab to shift focus to this component.

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 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 size
  public Dimension size()
Return the size of the widget.
Returns:
size of cell.
Overrides:
size in class Component
 o minimumSize
  public Dimension minimumSize()
Return the minimum size. Calculated using font metrics.
Returns:
minimum size of cell.
Overrides:
minimumSize in class Component
 o preferredSize
  public Dimension preferredSize()
Return the preferred size.
Returns:
preferred size of cell.
Overrides:
preferredSize in class Component
 o setText
  public 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 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 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 getColumns
  public int getColumns()
Get number of columns.
Returns:
number of columns in cell.
 o appendText
  public void appendText(String str)
Append text to the end.
Parameters:
str - text to append to cell.
 o insertText
  public void insertText(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 removeText
  public void removeText(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 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 keyDown
  public boolean keyDown(Event e,
                         int key)
Handle keydown event.
Parameters:
e - event object.
key - key pressed.
Returns:
false.
Overrides:
keyDown in class Component
 o mouseDown
  public boolean mouseDown(Event e,
                           int x,
                           int y)
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:
mouseDown in class Component
 o mouseDrag
  public boolean mouseDrag(Event e,
                           int x,
                           int y)
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:
mouseDrag in class Component
 o mouseUp
  public boolean mouseUp(Event e,
                         int x,
                         int y)
Handle mouse up event.
Parameters:
e - event object.
x - x coordinate of the mouse click point.
y - y coordinate of the mouse click point.
Returns:
false.
Overrides:
mouseUp in class Component
 o gotFocus
  public boolean gotFocus(Event e,
                          Object o)
Called when this component got focus.
Parameters:
e - event object.
o - event argument object.
Returns:
false.
Overrides:
gotFocus 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 lostFocus
  public boolean lostFocus(Event e,
                           Object o)
Called when this component lost focus.
Parameters:
e - event object.
o - event argument object.
Returns:
false.
Overrides:
lostFocus 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.
Overrides:
tabbable in class Component

All Packages  Class Hierarchy  This Package  Previous  Next  Index