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 NameProperty TypeDescription
CaseSensitiveboolean Case sensitive when matching text.
Forceboolean True if only items in the item list are allowed.
Autoboolean Item list window popping mode.
Popupedboolean True if item list window is popped up.
SelectedObjectsObject (Indexed) List of selected items.
SelectedIndexesint (Indexed) List of selected item indexes.

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

See Also:
TextEdit

Constructor Index

 o ListText()
Construct an empty ListText component.
 o ListText(int)
Construct a ListText with cols columns.
 o ListText(String)
Construct a ListText with str as the initial value.
 o ListText(String, int)
Construct a ListText with str as the initial value and cols columns.

Method Index

 o add(String)
Add an item to the list.
 o addItemListener(ItemListener)
Add an item listener.
 o finalize()
Popdown the list window.
 o getSelectedObjects()
Get the list of the selected items.
 o isAuto()
Return true if auto mode is enabled.
 o isCaseSensitive()
Get case sensitive setting.
 o isForce()
Get the force option flag.
 o isPopuped()
Return true if the item list window is popped up.
 o popdown()
Close the list window.
 o popup()
Popup a new list window.
 o processActionEvent(ActionEvent)
Process and dispatch action event.
 o processEvent(AWTEvent)
Process and dispatch event.
 o processItemEvent(ItemEvent)
Process and dispatch item event.
 o processKeyEvent(KeyEvent)
Process key event.
 o processMouseEvent(MouseEvent)
Process mouse event.
 o remove(String)
Delete an item from the list.
 o removeAll()
Delete all items from the list.
 o removeItemListener(ItemListener)
Remove an item listener.
 o setAuto(boolean)
In auto mode, user key or mouse click input cause the item list window to popup.
 o setCaseSensitive(boolean)
Set case sensitive to true or false.
 o setForce(boolean)
Set force option to true of false.

Constructors

 o ListText
 public ListText()
Construct an empty ListText component.

 o ListText
 public ListText(int cols)
Construct a ListText with cols columns.

Parameters:
cols - number of columns.
 o ListText
 public ListText(String str)
Construct a ListText with str as the initial value.

Parameters:
str - initial text.
 o 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.

Methods

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

 o isAuto
 public boolean isAuto()
Return true if auto mode is enabled.

Returns:
auto mode.
 o add
 public synchronized void add(String item)
Add an item to the list.

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

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

 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 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.
Overrides:
processActionEvent in class Cell
 o processEvent
 public void processEvent(AWTEvent e)
Process and dispatch event.

Parameters:
e - event object.
Overrides:
processEvent in class Cell
 o processMouseEvent
 public void processMouseEvent(MouseEvent e)
Process mouse event.

Parameters:
e - mouse event.
Overrides:
processMouseEvent in class Cell
 o processKeyEvent
 public void processKeyEvent(KeyEvent e)
Process key event.

Parameters:
e - key event.
Overrides:
processKeyEvent in class Cell
 o popup
 public synchronized void popup()
Popup a new list window.

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

 o isPopuped
 public boolean isPopuped()
Return true if the item list window is popped up.

Returns:
true if window popped up.
 o finalize
 public void finalize()
Popdown the list window.

Overrides:
finalize in class Object
 o 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