All Packages Class Hierarchy This Package Previous Next Index
Class tea.set.ListText
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Canvas
|
+----tea.set.Cell
|
+----tea.set.ListText
- public class ListText
- extends Cell
- implements TextEdit, ItemSelectable
ListText is a list based text edit widget. A list of words are
associated with each ListText. When an user types in the ListText,
ListText automatically searchs for the best match from the
list. There are options to make the search case sensitive or
otherwise. Users can also specify if only words from the list
are allowed by calling setForce(). This method should be called
after all add() methods are done if ListText is initialized
to a default text value. Because setForce will do
an immediate check to see if the current value is on the list,
an error message will be issued if the current value is not
empty and it's not on the list.
When an item is selected from the list window, an ItemEvent event
is triggered. Events defined in Cell is also inherited.
ListText itself does not draw a border around the text area. Use
Effect3D to add a border if desired:
add(new Effect3D(new ListText(cols), Effect3D.LOWERED));
Known bug: In JDK 1.0.1, On Win32 architectures, the coordinate (x,
y) is relative to the current component. On XWindow, the coordinate
(x, y) is relative to the window manager screen.
In JDK 1.0.2, all coordinate is relative to the screen. Therefore,
this version assumes the 1.0.2 semantics. It may not work with
browsers with 1.0.1 equivalent Java VM. Netscape 3.0 has yet another
interpretation of the window location. We try to use JDK 1.0.2 as
the standard.
If a TextList widget is used
inside a dialog, the list window will be covered by the dialog.
There is no obvious way to disable dialog from always shown on
top of list window. Therefore, if you need to popup a subwindow, use
Frame instead.
ListText supports the following properties:
Property Name | Property Type | Description |
CaseSensitive | boolean |
Case sensitive when matching text. |
Force | boolean |
True if only items in the item list are allowed. |
Auto | boolean |
Item list window popping mode. |
Popuped | boolean |
True if item list window is popped up. |
SelectedObjects | Object (Indexed) |
List of selected items. |
SelectedIndexes | int (Indexed) |
List of selected item indexes. |
ListText generates the following events:
Event Type | Event ID | Generated |
Description |
ActionEvent | ActionEvent.ACTION_PERFORMED |
Return or Tab key, or text changed through setText(). |
ActionEvent.getActionCommand() contains the text. |
ItemEvent | ItemEvent.SELECTED |
Item selected from list. |
ItemEvent.getItem() contains the selected item, and
ItemEvent.getStateChange() is 0. |
- See Also:
- TextEdit
-
ListText()
- Construct an empty ListText component.
-
ListText(int)
- Construct a ListText with cols columns.
-
ListText(String)
- Construct a ListText with str as the initial value.
-
ListText(String, int)
- Construct a ListText with str as the initial value and cols
columns.
-
add(String)
- Add an item to the list.
-
addItemListener(ItemListener)
- Add an item listener.
-
finalize()
- Popdown the list window.
-
getSelectedObjects()
- Get the list of the selected items.
-
isAuto()
- Return true if auto mode is enabled.
-
isCaseSensitive()
- Get case sensitive setting.
-
isForce()
- Get the force option flag.
-
isPopuped()
- Return true if the item list window is popped up.
-
popdown()
- Close the list window.
-
popup()
- Popup a new list window.
-
processActionEvent(ActionEvent)
- Process and dispatch action event.
-
processEvent(AWTEvent)
- Process and dispatch event.
-
processItemEvent(ItemEvent)
- Process and dispatch item event.
-
processKeyEvent(KeyEvent)
- Process key event.
-
processMouseEvent(MouseEvent)
- Process mouse event.
-
remove(String)
- Delete an item from the list.
-
removeAll()
- Delete all items from the list.
-
removeItemListener(ItemListener)
- Remove an item listener.
-
setAuto(boolean)
- In auto mode, user key or mouse click input cause the item list
window to popup.
-
setCaseSensitive(boolean)
- Set case sensitive to true or false.
-
setForce(boolean)
- Set force option to true of false.
ListText
public ListText()
- Construct an empty ListText component.
ListText
public ListText(int cols)
- Construct a ListText with cols columns.
- Parameters:
- cols - number of columns.
ListText
public ListText(String str)
- Construct a ListText with str as the initial value.
- Parameters:
- str - initial text.
ListText
public ListText(String str,
int cols)
- Construct a ListText with str as the initial value and cols
columns.
- Parameters:
- str - initial text.
- cols - number of columns.
setCaseSensitive
public synchronized void setCaseSensitive(boolean t)
- Set case sensitive to true or false.
- Parameters:
- t - case sensitivity.
isCaseSensitive
public boolean isCaseSensitive()
- Get case sensitive setting.
- Returns:
- true if case is sensitive.
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.
isForce
public boolean isForce()
- Get the force option flag.
- Returns:
- true if ListText is in force mode.
setAuto
public void setAuto(boolean f)
- In auto mode, user key or mouse click input cause the item list
window to popup. If auto mode is false, the item list window is
not poped up automatically, but only through the call of popup()
method.
isAuto
public boolean isAuto()
- Return true if auto mode is enabled.
- Returns:
- auto mode.
add
public synchronized void add(String item)
- Add an item to the list.
- Parameters:
- item - list item string.
remove
public synchronized void remove(String item)
- Delete an item from the list.
- Parameters:
- item - list item string.
removeAll
public synchronized void removeAll()
- Delete all items from the list.
addItemListener
public void addItemListener(ItemListener listener)
- Add an item listener.
- Parameters:
- listener - item listener.
removeItemListener
public void removeItemListener(ItemListener listener)
- Remove an item listener.
- Parameters:
- listener - item listener.
processItemEvent
public void processItemEvent(ItemEvent e)
- Process and dispatch item event.
- Parameters:
- e - item event.
processActionEvent
public void processActionEvent(ActionEvent e)
- Process and dispatch action event.
- Parameters:
- e - action event.
- Overrides:
- processActionEvent in class Cell
processEvent
public void processEvent(AWTEvent e)
- Process and dispatch event.
- Parameters:
- e - event object.
- Overrides:
- processEvent in class Cell
processMouseEvent
public void processMouseEvent(MouseEvent e)
- Process mouse event.
- Parameters:
- e - mouse event.
- Overrides:
- processMouseEvent in class Cell
processKeyEvent
public void processKeyEvent(KeyEvent e)
- Process key event.
- Parameters:
- e - key event.
- Overrides:
- processKeyEvent in class Cell
popup
public synchronized void popup()
- Popup a new list window.
popdown
public synchronized void popdown()
- Close the list window.
isPopuped
public boolean isPopuped()
- Return true if the item list window is popped up.
- Returns:
- true if window popped up.
finalize
public void finalize()
- Popdown the list window.
- Overrides:
- finalize in class Object
getSelectedObjects
public Object[] getSelectedObjects()
- Get the list of the selected items.
- Returns:
- list of selected items.
All Packages Class Hierarchy This Package Previous Next Index