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
-
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.
-
appendText(String)
- Append text to the end.
-
clearSelection()
- Clear selection.
-
getColumns()
- Get number of columns.
-
getCursorPos()
- Get cursor position.
-
getSelectedText()
- Return selected (highlighted) text.
-
getSelectionEnd()
- Get the end position of selection.
-
getSelectionStart()
- Get the starting position of selection.
-
getText()
- Get string value.
-
gotFocus(Event, Object)
- Called when this component got focus.
-
insertText(String, int)
- Insert text at the position.
-
isEditable()
- Return true if editable (default).
-
keyDown(Event, int)
- Handle keydown event.
-
lostFocus(Event, Object)
- Called when this component lost focus.
-
minimumSize()
- Return the minimum size.
-
mouseDown(Event, int, int)
- Handle mouse down event.
-
mouseDrag(Event, int, int)
- Handle mouse draw event.
-
mouseUp(Event, int, int)
- Handle mouse up event.
-
paint(Graphics)
- Paint widget.
-
preferredSize()
- Return the preferred size.
-
removeText(int, int)
- Remove text in the range.
-
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.
-
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.
-
size()
- Return the size of the widget.
-
tabbable()
- Allow tab to shift focus to this component.
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 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.
size
public Dimension size()
- Return the size of the widget.
- Returns:
- size of cell.
- Overrides:
- size in class Component
minimumSize
public Dimension minimumSize()
- Return the minimum size. Calculated using font metrics.
- Returns:
- minimum size of cell.
- Overrides:
- minimumSize in class Component
preferredSize
public Dimension preferredSize()
- Return the preferred size.
- Returns:
- preferred size of cell.
- Overrides:
- preferredSize in class Component
setText
public 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 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 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 void selectAll()
- Select all text.
clearSelection
public void clearSelection()
- Clear selection.
getColumns
public int getColumns()
- Get number of columns.
- Returns:
- number of columns in cell.
appendText
public void appendText(String str)
- Append text to the end.
- Parameters:
- str - text to append to cell.
insertText
public void insertText(String str,
int pos)
- Insert text at the position.
- Parameters:
- str - text to insert.
- pos - insertion position.
setCursorPos
public void setCursorPos(int pos)
- Set cursor at position.
- Parameters:
- pos - cursor position.
getCursorPos
public int getCursorPos()
- Get cursor position.
- Returns:
- cursor position.
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.
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).
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
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
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
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
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
requestFocus
public void requestFocus()
- Override requestFocus to set focus to true, needed when already has
focus.
- Overrides:
- requestFocus in class Component
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
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.
- Overrides:
- tabbable in class Component
All Packages Class Hierarchy This Package Previous Next Index