All Packages Class Hierarchy This Package Previous Next Index
Class tea.set.Spinner
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.Panel
|
+----tea.set.Spinner
- public class Spinner
- extends Panel
- implements TextEdit
Spinner widget is a TextEdit with scrollable list. The type of the
Spinner can either be a number, or a list of strings. If a numeric
Spinner is used, the values are defined by a low and high integer
range. Users can click on the up or down button to increment or
decrement the value within the specified range. If a string list
is used, users can click the up or down button to go the the next
or previous string in the list. Editing can optionally be enabled.
If editing is done in string list mode, when user hit return or tab
key, the newly entered text is inserted to the list at current
position. By default editable is set to false.
Example:
Spinner spinner = new Spinner("first|second|third|forth", "|");
Spinner supports the following properties:
Property Name | Property Type | Description |
Numeric | boolean (Readonly) |
True if Spinner is in numeric mode. |
RangeLow | int |
Lower bound of the numeric range. |
RangeHigh | int |
Higher bound of the numeric range. |
Items | String[] (Readonly) |
Items list of the spinner. |
Current | int |
The current value or index. |
InsertMode | boolean |
Text insert (overwrite) mode. |
Text | String |
Current text. |
SelectedText | String (Readonly) |
Selected text string. |
Editable | boolean |
Editable flag. |
SelectionStart | int (Readonly) |
Starting index of select substring. |
SelectionEnd | int (Readonly) |
Ending index of selected substring. |
Columns | int (Readonly) |
Width in characters. |
CursorPos | int |
Cursor position. |
Spinner generates the following events:
Event Type | Event ID | Generated |
Description |
ActionEvent | ActionEvent.ACTION_PERFORMED |
Return or Tab key, or up/down spin button is pressed. |
ActionEvent.getActionCommand() contains the text. |
TextEvent | TextEvent.TEXT_VALUE_CHANGED |
Text changed by user. |
Generated for every key stroke. |
- See Also:
- ListText
-
eventMgr
- EventMgr object handles added event processing and dispatching.
-
Spinner()
- Construct an empty item list spinner with border.
-
Spinner(int, int)
- Construct a numeric spinner with allowable values in the range
specified by low and high.
-
Spinner(int, int, boolean)
- Construct a numeric spinner with allowable values in the range
specified by low and high.
-
Spinner(String[])
- Construct a list spinner using the strings in items.
-
Spinner(String[], boolean)
- Construct a list spinner using the strings in items.
-
add(String)
- Add an item to the list.
-
addActionListener(ActionListener)
- Add an action listener.
-
addTextListener(TextListener)
- Add an text listener.
-
append(String)
- Append text to the end.
-
clearSelection()
- Clear selection.
-
getColumns()
- Returns the number of columns in this TextEdit.
-
getCurrent()
- If Spinner is in number mode, return the current value as integer.
-
getCursorPos()
- Get cursor position.
-
getItems()
- Get the item list of the spinner.
-
getRangeHigh()
- Get the higher bound of the numeric range.
-
getRangeLow()
- Get the lower bound of the numeric range.
-
getSelectedText()
- Return selected (highlighted) text.
-
getSelectionEnd()
- Get the end position of selection.
-
getSelectionStart()
- Get the starting position of selection.
-
getText()
- Get text value.
-
insert(String, int)
- Insert text at the position.
-
isEditable()
- Return true if editable (default).
-
isInsertMode()
- Get the insertion mode flag.
-
isNumeric()
- Get the mode of this spinner.
-
processActionEvent(ActionEvent)
- Process and dispatch action event.
-
processEvent(AWTEvent)
- Process and dispatch event.
-
processTextEvent(TextEvent)
- Process and dispatch text event.
-
remove(int, int)
- Remove text in the range.
-
remove(String)
- Remove the specified item from the list.
-
removeActionListener(ActionListener)
- Remove an action listener.
-
removeTextListener(TextListener)
- Remove an text listener.
-
select(int, int)
- Select the text in the range.
-
selectAll()
- Select all text.
-
setColumns(int)
- Sets the number of columns in this TextEdit.
-
setCurrent(int)
- Set the current item to the item at specified index.
-
setCursorPos(int)
- Set cursor at position.
-
setEditable(boolean)
- Set editable to true of false.
-
setInsertMode(boolean)
- Set insertion mode to true or false (overwrite).
-
setRange(int, int)
- Set the range for the numeric spinner.
-
setRangeHigh(int)
- Set the higher bound of the numeric range.
-
setRangeLow(int)
- Set the higher bound of the numeric range.
-
setText(String)
- Set the value of text.
eventMgr
protected EventMgr eventMgr
- EventMgr object handles added event processing and dispatching.
Spinner
public Spinner()
- Construct an empty item list spinner with border.
Spinner
public Spinner(int low,
int high)
- Construct a numeric spinner with allowable values in the range
specified by low and high. The low value is shown initially.
A border will be drawn around the text area by default.
- Parameters:
- low - lower bound of range.
- high - higher bound of range.
Spinner
public Spinner(int low,
int high,
boolean border)
- Construct a numeric spinner with allowable values in the range
specified by low and high. The low value is shown initially.
If border is true, a 3D border will be drawn around the text
area.
- Parameters:
- low - lower bound of range.
- high - higher bound of range.
- border - draw 3D border if true.
Spinner
public Spinner(String items[])
- Construct a list spinner using the strings in items. If Spinner
is editable, user can enter new items by entering a new text
value and hit return key. The first string in the list is
shown initially. A border will be drawn around the text area
by default.
- Parameters:
- items - items list for list spinner.
Spinner
public Spinner(String items[],
boolean border)
- Construct a list spinner using the strings in items. If Spinner
is editable, user can enter new items by entering a new text
value and hit return key. The first string in the list is
shown initially. If border is true, a 3D border will be drawn
around the text area.
- Parameters:
- items - items list for list spinner.
- border - draw 3D border if true.
getColumns
public int getColumns()
- Returns the number of columns in this TextEdit.
setColumns
public void setColumns(int columns)
- Sets the number of columns in this TextEdit.
- Parameters:
- columns - the number of columns
setRange
public synchronized void setRange(int low,
int high)
- Set the range for the numeric spinner. The spinner will be changed
to numeric and the low value will be shown. Spinner editable is
set to false by this method.
- Parameters:
- low - lower bound of range.
- high - higher bound of range.
isNumeric
public boolean isNumeric()
- Get the mode of this spinner.
- Returns:
- true if spinner is in numeric mode, false if the spinner
is in list mode.
setRangeLow
public void setRangeLow(int low)
- Set the higher bound of the numeric range.
- Parameters:
- low - lower bound of the range.
getRangeLow
public int getRangeLow()
- Get the lower bound of the numeric range. If this spinner is
not in numeric mode, -1 is returned.
- Returns:
- the lower bound of the numeric range.
setRangeHigh
public void setRangeHigh(int high)
- Set the higher bound of the numeric range.
- Parameters:
- high - higher bound of the range.
getRangeHigh
public int getRangeHigh()
- Get the higher bound of the numeric range. If this spinner is
not in numeric mode, -1 is returned.
- Returns:
- the higher bound of the numeric range.
getItems
public String[] getItems()
- Get the item list of the spinner.
- Returns:
- the spinner item list.
add
public synchronized void add(String item)
- Add an item to the list. If the type of spinner is numeric, it
will be changed to list. The new item is appended to the end
of the list.
- Parameters:
- item - list item.
remove
public synchronized void remove(String item)
- Remove the specified item from the list. If the item removed is
currently displayed, then display the previous item.
- Parameters:
- item - list item.
setCurrent
public synchronized void setCurrent(int idx)
- Set the current item to the item at specified index. If the Spinner
is in number mode, the index must be in the range specified.
Otherwise it must be less than the total number of items in the
item list.
- Parameters:
- idx - current value if numeric spinner, or item index if
list spinner.
getCurrent
public int getCurrent()
- If Spinner is in number mode, return the current value as integer.
Otherwise, return the current index of the item inside the item
list.
- Returns:
- current index or value.
setInsertMode
public void setInsertMode(boolean mode)
- Set insertion mode to true or false (overwrite).
- Parameters:
- mode - true for overwrite mode, false for insert mode.
isInsertMode
public boolean isInsertMode()
- Get the insertion mode flag.
- Returns:
- true if it is in insert mode.
setText
public void setText(String t)
- Set the value of text.
- Parameters:
- t - cell text.
getText
public String getText()
- Get text 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 of false.
- Parameters:
- t - cell editable flag.
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.
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 void setCursorPos(int pos)
- Set cursor at position.
- Parameters:
- pos - cursor position.
getCursorPos
public int getCursorPos()
- Get cursor position.
- Returns:
- cursor position.
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.
addActionListener
public void addActionListener(ActionListener listener)
- Add an action listener.
- Parameters:
- listener - action listener.
removeActionListener
public void removeActionListener(ActionListener listener)
- Remove an action listener.
- Parameters:
- listener - action listener.
addTextListener
public void addTextListener(TextListener listener)
- Add an text listener.
- Parameters:
- listener - text listener.
removeTextListener
public void removeTextListener(TextListener listener)
- Remove an text listener.
- Parameters:
- listener - text listener.
processEvent
public void processEvent(AWTEvent e)
- Process and dispatch event.
- Parameters:
- e - event object.
- Overrides:
- processEvent in class Container
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.
All Packages Class Hierarchy This Package Previous Next Index