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

Constructor Index

 o Spinner(int, int)
Construct a numeric spinner with allowable values in the range specified by low and high.
 o Spinner(int, int, boolean)
Construct a numeric spinner with allowable values in the range specified by low and high.
 o Spinner(String, String)
Construct a list spinner by extracting fields from the string using delim as the delimiter.
 o Spinner(String, String, boolean)
Construct a list spinner by extracting fields from the string using delim as the delimiter.
 o Spinner(String[])
Construct a list spinner using the strings in items.
 o Spinner(String[], boolean)
Construct a list spinner using the strings in items.
 o Spinner(Vector)
Construct a list spinner using the strings in items.
 o Spinner(Vector, boolean)
Construct a list spinner using the strings in items.

Method Index

 o action(Event, Object)
Action event is generated when the value of spinner changes.
 o addItem(String)
Add an item to the list.
 o appendText(String)
Append text to the end.
 o clearSelection()
Clear selection.
 o getColumns()
Get number of columns.
 o getCurrent()
If Spinner is in number mode, return the current value as integer.
 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 text value.
 o insertText(String, int)
Insert text at the position.
 o isEditable()
Return true if editable (default).
 o removeItem(String)
Remove the specified item from the list.
 o removeText(int, int)
Remove text in the range.
 o select(int, int)
Select the text in the range.
 o selectAll()
Select all text.
 o setCurrent(int)
Set the current item to the item at specified index.
 o setCursorPos(int)
Set cursor at position.
 o setEditable(boolean)
Set editable to true of false.
 o setInsertMode(boolean)
Set insertion mode to true or false (overwrite).
 o setRange(int, int)
Set the range for the numeric spinner.
 o setText(String)
Set the value of text.

Constructors

 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.

Methods

 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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
 o setInsertMode
  public void setInsertMode(boolean mode)
Set insertion mode to true or false (overwrite).
Parameters:
mode - true for overwrite mode, false for insert mode.
 o setText
  public void setText(String t)
Set the value of text.
Parameters:
t - cell text.
 o getText
  public String getText()
Get text 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 of false.
Parameters:
t - cell editable flag.
 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.

All Packages  Class Hierarchy  This Package  Previous  Next  Index