All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class tea.set.ComboBox

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----tea.set.ComboBox

public class ComboBox
extends Panel
implements TextEdit, ItemSelectable
ComboBox is a text edit widget that supports selecting text item from a dropdown menu, in addition to inline editing. When the dropdown menu is popped up, user typed text will be used to find the best match in the list and scrolled up to the top. Users can be restricted to enter text only on the item list, or any text.

ComboBox supports the following properties:
Property NameProperty TypeDescription
CaseSensitiveboolean True if case sensitive when match text.
Forceboolean True if user only allowed to enter text in the item list.
SelectedObjectsObject[] (Readonly) list of selected items in the item list.
InsertModeboolean True for insert mode, and false for overwrite mode.
TextString Text in the cell.
SelectedTextString (Readonly) Selected (highlighted) Text in the cell.
Editableboolean Allow editing or not.
SelectionStartint (Readonly) Starting index of selected text.
SelectionEndint (Readonly) End index of selected text.
Columnsint Text columns in the cell.
CursorPosint Cursor position in the cell.

ComboBox generates the following events:
Event TypeEvent IDGenerated Description
ActionEventActionEvent.ACTION_PERFORMED Return or Tab key, or text changed through setText(). ActionEvent.getActionCommand() contains the text.
ItemEventItemEvent.SELECTED Item selected from list. ItemEvent.getItem() contains the selected item, and ItemEvent.getStateChange() is 0.
TextEventTextEvent.TEXT_VALUE_CHANGED Text changed by user. Generated for every key stroke.

See Also:
TextEdit, ListText

Variable Index

 o eventMgr
EventMgr object handles added event processing and dispatching.

Constructor Index

 o ComboBox()
Construct a new ComboBox, the initial size is 0.
 o ComboBox(int)
Construct a ComboBox with the specified number of columns.
 o ComboBox(String)
Construct a ComboBox with the string as the initial text and the string length as the size.
 o ComboBox(String, int)
Construct a ComboBox with the string as the initial text and the specified num as the size.

Method Index

 o add(String)
Add an item to the item list.
 o addActionListener(ActionListener)
Add an action listener.
 o addItemListener(ItemListener)
Add an item listener.
 o addTextListener(TextListener)
Add an text listener.
 o append(String)
Append text to the end.
 o clearSelection()
Clear selection.
 o getColumns()
Returns the number of columns in this TextEdit.
 o getCursorPos()
Get cursor position.
 o getSelectedObjects()
Get the items selected in the item list.
 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 current text value.
 o insert(String, int)
Insert text at the position.
 o isCaseSensitive()
Get case sensitive setting.
 o isEditable()
Return true if editable (default).
 o isForce()
Get the force option flag.
 o isInsertMode()
Get the insertion mode flag.
 o popdown()
Close the item list window.
 o popup()
Drop down the item list menu.
 o processActionEvent(ActionEvent)
Process and dispatch action event.
 o processEvent(AWTEvent)
Process and dispatch event.
 o processItemEvent(ItemEvent)
Process and dispatch item event.
 o processTextEvent(TextEvent)
Process and dispatch text event.
 o remove(int, int)
Remove text in the range.
 o remove(String)
Delete an item from the list.
 o removeActionListener(ActionListener)
Remove an action listener.
 o removeAll()
Delete all items from the list.
 o removeItemListener(ItemListener)
Remove an item listener.
 o removeTextListener(TextListener)
Remove an text listener.
 o select(int, int)
Select the text in the range.
 o selectAll()
Select all text.
 o setCaseSensitive(boolean)
Set case sensitive to true or false.
 o setColumns(int)
Sets the number of columns in this TextEdit.
 o setCursorPos(int)
Set cursor at position.
 o setEditable(boolean)
Set editable to true of false.
 o setForce(boolean)
Set force option to true of false.
 o setInsertMode(boolean)
Set insertion mode to true or false (overwrite).
 o setText(String)
Set the value of text.

Variables

 o eventMgr
 protected EventMgr eventMgr
EventMgr object handles added event processing and dispatching.

Constructors

 o ComboBox
 public ComboBox()
Construct a new ComboBox, the initial size is 0. Use setColunms() to change the size.

 o ComboBox
 public ComboBox(int cols)
Construct a ComboBox with the specified number of columns.

Parameters:
cols - number of columns.
 o ComboBox
 public ComboBox(String str)
Construct a ComboBox with the string as the initial text and the string length as the size.

Parameters:
str - initial string.
 o ComboBox
 public ComboBox(String str,
                 int cols)
Construct a ComboBox with the string as the initial text and the specified num as the size.

Parameters:
str - initial string.
cols - number of columns.

Methods

 o getColumns
 public int getColumns()
Returns the number of columns in this TextEdit.

 o setColumns
 public void setColumns(int columns)
Sets the number of columns in this TextEdit.

Parameters:
columns - the number of columns
 o setCaseSensitive
 public synchronized void setCaseSensitive(boolean t)
Set case sensitive to true or false.

Parameters:
t - case sensitivity.
 o isCaseSensitive
 public boolean isCaseSensitive()
Get case sensitive setting.

Returns:
true if case is sensitive.
 o setForce
 public synchronized void setForce(boolean t)
Set force option to true of false. If force option is true, only the words from the list are allowed in the text edit.

Parameters:
t - force mode.
 o isForce
 public boolean isForce()
Get the force option flag.

Returns:
true if ListText is in force mode.
 o add
 public synchronized void add(String item)
Add an item to the item list.

Parameters:
item - item string.
 o remove
 public synchronized void remove(String item)
Delete an item from the list.

Parameters:
item - item string.
 o removeAll
 public synchronized void removeAll()
Delete all items from the list.

Overrides:
removeAll in class Container
 o addItemListener
 public void addItemListener(ItemListener listener)
Add an item listener.

Parameters:
listener - item listener.
 o removeItemListener
 public void removeItemListener(ItemListener listener)
Remove an item listener.

Parameters:
listener - item listener.
 o addActionListener
 public void addActionListener(ActionListener listener)
Add an action listener.

Parameters:
listener - action listener.
 o removeActionListener
 public void removeActionListener(ActionListener listener)
Remove an action listener.

Parameters:
listener - action listener.
 o addTextListener
 public void addTextListener(TextListener listener)
Add an text listener.

Parameters:
listener - text listener.
 o removeTextListener
 public void removeTextListener(TextListener listener)
Remove an text listener.

Parameters:
listener - text listener.
 o processItemEvent
 public void processItemEvent(ItemEvent e)
Process and dispatch item event.

Parameters:
e - item event.
 o processActionEvent
 public void processActionEvent(ActionEvent e)
Process and dispatch action event.

Parameters:
e - action event.
 o processTextEvent
 public void processTextEvent(TextEvent e)
Process and dispatch text event.

Parameters:
e - text event.
 o processEvent
 public void processEvent(AWTEvent e)
Process and dispatch event.

Parameters:
e - event object.
Overrides:
processEvent in class Container
 o popup
 public synchronized void popup()
Drop down the item list menu.

 o popdown
 public synchronized void popdown()
Close the item list window.

 o getSelectedObjects
 public Object[] getSelectedObjects()
Get the items selected in the item list.

Returns:
selected item list.
 o setInsertMode
 public void setInsertMode(boolean mode)
Set insertion mode to true or false (overwrite).

Parameters:
true - for insert mode and false for overwrite mode.
 o isInsertMode
 public boolean isInsertMode()
Get the insertion mode flag.

Returns:
true if it is in insert mode.
 o setText
 public void setText(String t)
Set the value of text.

Parameters:
t - cell text.
 o getText
 public String getText()
Get current 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 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 append
 public void append(String str)
Append text to the end.

Parameters:
str - text to append to cell.
 o insert
 public void insert(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 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.

All Packages  Class Hierarchy  This Package  Previous  Next  Index