Class tea.set.Spinner
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", "|");
- See Also:
- ListText
-
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, String)
- Construct a list spinner by extracting fields from the string
using delim as the delimiter.
-
Spinner(String, String, boolean)
- Construct a list spinner by extracting fields from the string
using delim as the delimiter.
-
Spinner(String[])
- Construct a list spinner using the strings in items.
-
Spinner(String[], boolean)
- Construct a list spinner using the strings in items.
-
Spinner(Vector)
- Construct a list spinner using the strings in items.
-
Spinner(Vector, boolean)
- Construct a list spinner using the strings in items.
-
action(Event, Object)
- Action event is generated when the value of spinner changes.
-
addItem(String)
- Add an item to the list.
-
appendText(String)
- Append text to the end.
-
clearSelection()
- Clear selection.
-
getColumns()
- Get number of columns.
-
getCurrent()
- If Spinner is in number mode, return the current value as integer.
-
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 text value.
-
insertText(String, int)
- Insert text at the position.
-
isEditable()
- Return true if editable (default).
-
removeItem(String)
- Remove the specified item from the list.
-
removeText(int, int)
- Remove text in the range.
-
select(int, int)
- Select the text in the range.
-
selectAll()
- Select all text.
-
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.
-
setText(String)
- Set the value of text.
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.
Spinner
public Spinner(Vector items)
- Construct a list spinner using the strings in items.
A border will be drawn around text area by default.
- Parameters:
- items - items list for list spinner.
Spinner
public Spinner(Vector items,
boolean border)
- Construct a list spinner using the strings in items.
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.
Spinner
public Spinner(String str,
String delim)
- Construct a list spinner by extracting fields from the string
using delim as the delimiter. A border will be drawn around
the text area by default.
- Parameters:
- str - item list in delimited form.
- delim - delimiter.
Spinner
public Spinner(String str,
String delim,
boolean border)
- Construct a list spinner by extracting fields from the string
using delim as the delimiter. If border is true, a 3D border
will be drawn around the text area.
- Parameters:
- str - item list in delimited form.
- delim - delimiter.
- border - draw 3D border if true.
setRange
public 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.
- Parameters:
- low - lower bound of range.
- high - higher bound of range.
addItem
public void addItem(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.
removeItem
public void removeItem(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 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.
action
public boolean action(Event e,
Object arg)
- Action event is generated when the value of spinner changes.
The Event.arg points to this Spinner object.
- Parameters:
- e - event object.
- arg - event argument object.
- Overrides:
- action in class Component
setInsertMode
public void setInsertMode(boolean mode)
- Set insertion mode to true or false (overwrite).
- Parameters:
- mode - true for overwrite mode, false for 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.
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.
All Packages Class Hierarchy This Package Previous Next Index