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.
-
_selectVector
-
-
_sort
-
-
_strCompare
-
-
_userData
-
-
ListBox()
-
-
add(String)
- Adds an item to a list box.
-
add(String, int)
- Adds an item to a list box at the specified index.
-
add(String, int, Object)
- Adds an item with associated user data to a list box.
-
add(String, int, Object, boolean)
- Adds an item with associated user data to a list box,
overriding the Sort property while adding the item.
-
addSelectListener(SelectListener)
-
-
createAWTComponent(Component)
-
-
delete(int)
- Deletes the item with the given index from a listbox.
-
deleteAll()
- Removes all items from a list box.
-
find(String)
- Finds the index of the first listbox item that begins with
the specified string.
-
find(String, int, boolean)
- Finds the index of a listbox item that begins with or matches
the specified string.
-
getCount()
- Gets the number of items in a list box.
-
getMultipleSelection()
- Determines whether more than one list box item can be
selected at one time.
-
getSelected()
- Determines the selected item in a list box.
-
getSelected(int)
- Determines if the specified listbox item is selected.
-
getSelectedCount()
- Determines the number of selected items in a list box.
-
getSelectedList()
- Determines the number of selected items in a list box.
-
getSelectListeners()
-
-
getSort()
- Determines whether the items in a list box are sorted in
ascending alphanumeric order by default.
-
getText(int)
- Retrieves the text of the specified listbox item
or of the selected item.
-
getTopIndex()
- Gets the index of the listbox item that was last made visible by
calling setTopIndex.
-
getUserData(int)
- Gets the user data associated with the specified listbox
item.
-
getVisibleCount()
- Determines the number of visible lines in the listbox.
-
handleSelect(SelectEvent)
-
-
processAWTEvent(Event)
-
-
removeSelectListener(SelectListener)
-
-
replace(String, int)
- Replaces the string value of a listbox item.
-
replace(String, int, Object)
- Replaces the string and userdata values of a listbox item.
-
reset()
- Removes all items from the list box.
-
select(String)
- Finds a listbox item that begins with the specified string
and marks it selected.
-
select(String, int)
- Finds a listbox item that begins with the specified string
and marks it selected.
-
setMultipleSelection(boolean)
- Establishes whether more than one list box item can be
selected at one time.
-
setSelected(int)
- Selects the item with the given index in a listbox.
-
setSelected(int, boolean)
- Selects or deselects a listbox item.
-
setSort(boolean)
- Establishes whether the items in a list box will be sorted in
ascending alphanumeric order.
-
setTopIndex(int)
- Ensures that the listbox item with the given index will be visible.
-
setUserData(int, Object)
- Sets the user data for the item at the given index.
-
sort()
-
_userData
protected Vector _userData
_sort
protected boolean _sort
_selectVector
protected EventListenerVector _selectVector
_strCompare
protected static CompareRoutine _strCompare
ListBox
public ListBox()
addSelectListener
public synchronized void addSelectListener(SelectListener l)
getSelectListeners
public synchronized EventListenerVector getSelectListeners()
handleSelect
public synchronized void handleSelect(SelectEvent data)
removeSelectListener
public synchronized void removeSelectListener(SelectListener l)
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
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
true
is 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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
reset
public synchronized void reset()
- Removes all items from the list box.
- See Also:
- delete, deleteAll
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
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
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
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
createAWTComponent
protected Component createAWTComponent(Component parent)
- Overrides:
- createAWTComponent in class Component
processAWTEvent
public boolean processAWTEvent(Event event)
- Overrides:
- processAWTEvent in class Component
sort
protected void sort()
All Packages Class Hierarchy This Package Previous Next Index