Class powersoft.jcm.ui.ListBox
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class powersoft.jcm.ui.ListBox

java.lang.Object
   |
   +----powersoft.jcm.ui.Component
           |
           +----powersoft.jcm.ui.ListBox

public class ListBox
extends Component
The ListBox component presents the user with a scrolling list of text items. The list can be set up so that the user can pick one item or multiple items.

Variable Index

 o _selectVector
 o _sort
 o _strCompare
 o _userData

Constructor Index

 o ListBox()

Method Index

 o add(String)
Adds an item to a list box.
 o add(String, int)
Adds an item to a list box at the specified index.
 o add(String, int, Object)
Adds an item with associated user data to a list box.
 o add(String, int, Object, boolean)
Adds an item with associated user data to a list box, overriding the Sort property while adding the item.
 o addSelectListener(SelectListener)
 o createAWTComponent(Component)
 o delete(int)
Deletes the item with the given index from a listbox.
 o deleteAll()
Removes all items from a list box.
 o find(String)
Finds the index of the first listbox item that begins with the specified string.
 o find(String, int, boolean)
Finds the index of a listbox item that begins with or matches the specified string.
 o getCount()
Gets the number of items in a list box.
 o getMultipleSelection()
Determines whether more than one list box item can be selected at one time.
 o getSelected()
Determines the selected item in a list box.
 o getSelected(int)
Determines if the specified listbox item is selected.
 o getSelectedCount()
Determines the number of selected items in a list box.
 o getSelectedList()
Determines the number of selected items in a list box.
 o getSelectListeners()
 o getSort()
Determines whether the items in a list box are sorted in ascending alphanumeric order by default.
 o getText(int)
Retrieves the text of the specified listbox item or of the selected item.
 o getTopIndex()
Gets the index of the listbox item that was last made visible by calling setTopIndex.
 o getUserData(int)
Gets the user data associated with the specified listbox item.
 o getVisibleCount()
Determines the number of visible lines in the listbox.
 o handleSelect(SelectEvent)
 o processAWTEvent(Event)
 o removeSelectListener(SelectListener)
 o replace(String, int)
Replaces the string value of a listbox item.
 o replace(String, int, Object)
Replaces the string and userdata values of a listbox item.
 o reset()
Removes all items from the list box.
 o select(String)
Finds a listbox item that begins with the specified string and marks it selected.
 o select(String, int)
Finds a listbox item that begins with the specified string and marks it selected.
 o setMultipleSelection(boolean)
Establishes whether more than one list box item can be selected at one time.
 o setSelected(int)
Selects the item with the given index in a listbox.
 o setSelected(int, boolean)
Selects or deselects a listbox item.
 o setSort(boolean)
Establishes whether the items in a list box will be sorted in ascending alphanumeric order.
 o setTopIndex(int)
Ensures that the listbox item with the given index will be visible.
 o setUserData(int, Object)
Sets the user data for the item at the given index.
 o sort()

Variables

 o _userData
  protected Vector _userData
 o _sort
  protected boolean _sort
 o _selectVector
  protected EventListenerVector _selectVector
 o _strCompare
  protected static CompareRoutine _strCompare

Constructors

 o ListBox
  public ListBox()

Methods

 o addSelectListener
  public synchronized void addSelectListener(SelectListener l)
 o getSelectListeners
  public synchronized EventListenerVector getSelectListeners()
 o handleSelect
  public synchronized void handleSelect(SelectEvent data)
 o removeSelectListener
  public synchronized void removeSelectListener(SelectListener l)
 o getCount
  public int getCount()
Gets the number of items in a list box.
Returns:
-1 if the underlying AWT component is not defined; otherwise the number of items in the list box.
See Also:
add, delete, getSelectedCount, getVisibleCount
 o getMultipleSelection
  public boolean getMultipleSelection()
Determines whether more than one list box item can be selected at one time.

Notes: Selecting an item deselects any previously selected item.

Returns:
If trueis returned, the user can select a set of items. If false is returned, only one item can be selected.
See Also:
setMultipleSelection, getSelected, setSelected, getSelectedCount
 o setMultipleSelection
  public void setMultipleSelection(boolean multiple)
Establishes whether more than one list box item can be selected at one time.

Notes: Selecting an item deselects any previously selected item.

Parameters:
multiple - If true, the list box supports selection of more than one item. If false, the user can select only one item at a time.
See Also:
getMultipleSelection, getSelected, setSelected, getSelectedCount
 o getSelected
  public int getSelected()
Determines the selected item in a list box.
Returns:
the zero-based index of the currently selected item. If no item is currently selected or if more than one item is selected, -1 is returned.
See Also:
setSelected, getSelectedCount, getSelectedList
 o setSelected
  public synchronized void setSelected(int index)
Selects the item with the given index in a listbox. If the index is -1, all items are deselected.
Parameters:
index - Specifies the zero-based index of a list box item.
See Also:
getSelected, getSelectedCount, getSelectedList
 o getSelectedCount
  public int getSelectedCount()
Determines the number of selected items in a list box.

Notes: This property applies to multiple selection list boxes only (MultipleSelection property is true).

Returns:
the number of currently selected items. If no item is currently selected or an error is detected, -1 is returned.
See Also:
getSelected, setSelected, getSelectedList
 o getSelectedList
  public int[] getSelectedList()
Determines the number of selected items in a list box.
Returns:
Returns an array of indices of the selected items or null if an error occurs. If no items are selected, the array will be empty. If the list box is a single selection list box, the returned array will contain at most one index.
See Also:
getSelected, setSelected, getSelectedCount
 o getSort
  public boolean getSort()
Determines whether the items in a list box are sorted in ascending alphanumeric order by default.

Notes: getSort returns true if the list box items are currently sorted. This means that the existing contents are in sorted order and that newly added items are added in sorted order.

Returns:
If true, the listbox items are sorted and new items will be added in sorted order. If false, new items will be added to the end of the list (the current list may or may not be sorted).
See Also:
setSort, add
 o setSort
  public synchronized void setSort(boolean sort)
Establishes whether the items in a list box will be sorted in ascending alphanumeric order.
Parameters:
sort - If true, the items currently in the listbox will be sorted and new items will be added in sorted order. If false, the items currently in the listbox will not be sorted and new items will be added to the end of the list.
See Also:
getSort, add
 o getTopIndex
  public int getTopIndex()
Gets the index of the listbox item that was last made visible by calling setTopIndex.
Returns:
the index of the listbox item that was last made visible by invoking the setTopIndex method.
See Also:
setTopIndex, getSort, setSort
 o setTopIndex
  public void setTopIndex(int index)
Ensures that the listbox item with the given index will be visible. The list of items is scrolled if necessary.
Parameters:
index - the index of the listbox item that is to be made visible
See Also:
getTopIndex, getSort, setSort
 o getVisibleCount
  public int getVisibleCount()
Determines the number of visible lines in the listbox. This is the maximum number of items that are visible at one time.

Notes: If the number of items in the listbox exceeds the VisibleCount property, a scroll bar is provided

Returns:
The number of visible lines in the list box.
See Also:
getCount
 o getSelected
  public boolean getSelected(int index)
Determines if the specified listbox item is selected.
Parameters:
item - Specifies the zero-based index of a listbox item.
Returns:
true if the item with the given index is selected; false otherwise.
See Also:
setSelected
 o setSelected
  public synchronized void setSelected(int index,
                                       boolean selected)
Selects or deselects a listbox item.
Parameters:
index - Specifies the zero-based index of the listbox item. If index is -1, selects or deselects all items if the MultipleSelection property is set.
selected - If true, item is selected. If false, item is deselected.
See Also:
getSelected
 o getText
  public String getText(int index)
Retrieves the text of the specified listbox item or of the selected item.
Parameters:
index - Specifies zero-based index of a list box item. The text of this item will be returned. If index is -1, the text of the selected item will be returned.
Returns:
The text of the item at the given index or the text of the selected item if the given index is -1. If index exceeds the number of items in the list box, null is returned.
See Also:
getSelected, setSelected, add
 o getUserData
  public Object getUserData(int index)
Gets the user data associated with the specified listbox item.

Notes: ArrayIndexOutOfBoundsException is thrown if index is out of range.

Parameters:
index - Specifies the zero-based index of a listbox item.
Returns:
If index does not refer to a listbox item, getUserData returns null; otherwise getUserData returns the user data object.
See Also:
setUserData, getText, getSelected, setSelected, add
 o setUserData
  public synchronized void setUserData(int index,
                                       Object userData)
Sets the user data for the item at the given index.

Notes: ArrayIndexOutOfBoundsException is thrown if index is out of range.

Parameters:
index - Specifies the zero-based index of a listbox item.
userData - Specifies the user data to associate with the listbox item.
See Also:
getUserData, getText, getSelected, setSelected, add
 o add
  public int add(String item)
Adds an item to a list box. The item has no user data associated with it and is added in sorted order if the Sort property is true.
Parameters:
item - The text of the item to be added to the list box.
Returns:
The zero-based index of the newly added item or -1 if an error occurs.
See Also:
getCount, getSort, setSort
 o add
  public int add(String item,
                 int index)
Adds an item to a list box at the specified index. The item has no user data associated with it.
Parameters:
item - The text of the item to be added to the list box.
index - Specifies the index at which to place item. If index is negative and the Sort property is true, item will be added in ascending alphanumeric order; otherwise item is added at the position specified by index or at the end of the list.
Returns:
The zero-based index of the newly added item or -1 if an error occurs.
See Also:
getCount, getSort, setSort
 o add
  public int add(String item,
                 int index,
                 Object userData)
Adds an item with associated user data to a list box.
Parameters:
item - The text of the item to be added to the list box.
index - Specifies the index at which to place item. If index is negative and the Sort property is true, item will be added in ascending alphanumeric order; otherwise item is added at the position specified by index or at the end of the list.
userData - Specifies the user data associated with the new item.
Returns:
The zero-based index of the newly added item or -1 if an error occurs.
See Also:
getCount, getSort, setSort
 o add
  public synchronized int add(String item,
                              int index,
                              Object userData,
                              boolean addInSortedOrder)
Adds an item with associated user data to a list box, overriding the Sort property while adding the item.
Parameters:
item - The text of the item to be added to the list box.
index - Specifies the index at which to place item. If index is negative and addInSortedOrder is true, item will be added in ascending alphanumeric order; otherwise item is added at the position specified by index or at the end of the list.
userData - Specifies the user data associated with the new item.
addInSortedOrder - If true and index is negative, item will be added in ascending alphanumeric order. If false, item is added at the position specified by index or at the end of the list.
Returns:
The zero-based index of the newly added item or -1 if an error occurs.
See Also:
getCount, getSort, setSort
 o delete
  public synchronized int delete(int index)
Deletes the item with the given index from a listbox.

Notes: To remove all items in the list use the deleteAll method.

Parameters:
index - Specifies the zero-based index of the item to be removed.
Returns:
The number of items remaining in the list, or -1 if an error occurred.
See Also:
add, deleteAll
 o deleteAll
  public synchronized boolean deleteAll()
Removes all items from a list box.

Notes: To remove a specific item from the list use the delete method.

Returns:
true if all items were successfully removed; false if an error occurs (e.g., no items were in the list).
See Also:
delete, reset
 o find
  public int find(String item)
Finds the index of the first listbox item that begins with the specified string.
Parameters:
item - the listbox item to locate.
Returns:
The index of the item or -1 if no corresponding item was found or an error occurred.
See Also:
add, replace
 o find
  public synchronized int find(String item,
                               int startAfter,
                               boolean exact)
Finds the index of a listbox item that begins with or matches the specified string.
Parameters:
item - the listbox item to locate.
startAfter - the index after which the search should begin. To start with the first item in the list, specify -1.
exact - if true, then the strings must match entirely; if false then a match occurs if the listbox entry begins with item.
Returns:
The index of the item or -1 if no corresponding item was found or an error occurred.
See Also:
add, replace
 o reset
  public synchronized void reset()
Removes all items from the list box.
See Also:
delete, deleteAll
 o replace
  public synchronized boolean replace(String value,
                                      int index)
Replaces the string value of a listbox item. Does not change the userdata value for that item.
Parameters:
value - the new string value for the listbox item.
index - the zero-based index for the listbox item to be replaced.
Returns:
false if the specified index is out of range; true if the listbox item was replaced.
See Also:
add, delete
 o replace
  public synchronized boolean replace(String value,
                                      int index,
                                      Object userData)
Replaces the string and userdata values of a listbox item.
Parameters:
value - the new string value for the listbox item.
index - the zero-based index for the listbox item to be replaced.
userData - the new user data value.
Returns:
false if the specified index is out of range; true if the listbox item was replaced.
See Also:
add, delete
 o select
  public int select(String item)
Finds a listbox item that begins with the specified string and marks it selected.
Parameters:
item - the listbox item to locate.
Returns:
The index of the item or -1 if no corresponding item was found or an error occurred.
See Also:
find, setSelected
 o select
  public synchronized int select(String item,
                                 int startAfter)
Finds a listbox item that begins with the specified string and marks it selected.
Parameters:
item - the listbox item to locate.
startAfter - the index after which the search should begin. To start with the first item in the list, specify -1.
Returns:
The index of the item or -1 if no corresponding item was found or an error occurred.
See Also:
find, setSelected
 o createAWTComponent
  protected Component createAWTComponent(Component parent)
Overrides:
createAWTComponent in class Component
 o processAWTEvent
  public boolean processAWTEvent(Event event)
Overrides:
processAWTEvent in class Component
 o sort
  protected void sort()

All Packages  Class Hierarchy  This Package  Previous  Next  Index