Component | +--Control | +--ListBoxpublic class ListBox
Encapsulates the Windows list box control.
Fields
Name | Description |
---|---|
NOMATCHES | While doing a search, if no matches are found, this is returned |
Constructors
Name | Description |
---|---|
ListBox() | Creates a basic win32 list box with default values for everything. |
Methods
Name | Description |
---|---|
addItem(Object item) | Adds an item to the list box. |
addOnDrawItem(DrawItemEventHandler value) | Adds an event handler for the OnDrawItem event notification. |
addOnMeasureItem(MeasureItemEventHandler value) | Adds an event handler for the OnMeasureItem event notification. |
addOnSelectionChange(EventHandler value) | Adds an event handler for the OnSelectionChange event notification. |
findString(String findString) | Finds the first item in the list that starts with the specified string. |
findString(String findString, int indexStart) | Finds the first item after the specified index that starts with the specified string. |
findStringExact(String findString) | Finds the first item in the list that is the same string as that specified in the findString parameter. |
findStringExact(String findString, int indexStart) | Finds the first item after the speicified index that is the same string as that specified in the findString parameter. |
getBorder() | Retrieves the current border setting. |
getColumnWidth() | In a multicolumn list box, returns the current width of each column in the list. |
getCreateParams() |
getDrawModepublic final int getDrawMode(); |
getDrawMode() | Indicates if the list box should avoid showing partial items. |
getIntegralHeight() | Returns the item at the given index. |
getItem(int index) | Returns a count of the total number of items in the list box. |
getItemCount() | Returns the height of an item in the list box if the drawMode is either NORMAL or OWNERDRAWFIXED. |
getItemHeight() | Returns the height of the given item in an OWNERDRAWVARIABLE style list box. |
getItemHeight(int index) | Returns a Rectangle object which describes the bounding rectangle around an item in the list. |
getItemRect(int index) | Returns an object array with all the items in the ListBox. |
getItems() | Indicates if the list box is multicolumn or not. |
getMultiColumn() | Returns the total height of the items in the list box. |
getPreferredHeight() | For normal list boxes, this indicates if the scroll bar will always be shown on the right side of the list, even if the number of list items is not enough to fill the entire list. |
getScrollAlwaysVisible() | Indicates whether the item at the supplied index is selected. |
getSelected(int index) | Returns the index of the currently selected item in the list if there is one. |
getSelectedIndex() | If multiselection is allowed, returns an array of all items that are currently selected. |
getSelectedIndices() | Returns the value of the currently selected item in the list,if there is one. |
getSelectedItem() | Controls how many items in the list box can be selected at a time. |
getSelectionStyle() | Indicates if the list box is sorted or not. |
getSorted() | Retrieves the index of the first visible item in a list box. |
getTopIndex() | Enables a list box to recognize and expand tab characters when drawing its strings. |
getUseTabStops() | Allows you to add an Item to the ListBox in a location you specify, as opposed to the end of the list. |
insertItem(int index, Object item) | Returns the index of the item at the given coordinates. |
itemFromPoint(Point p) | Returns the index of the item at the given coordinates. |
itemFromPoint(int x, int y) | Override this to guarantee that the list is refilled when necessary. |
recreateHandle() | Removes all items from the list box. |
removeAll() | Removes an individual item from the list box at the supplied index. |
removeItem(int index) | Removes the given handler for the OnDrawItem event. |
removeOnDrawItem(DrawItemEventHandler value) | Removes the given handler for the OnMeasureItem event. |
removeOnMeasureItem( MeasureItemEventHandler value) | Removes the given handler for the OnSelectionChange event. |
removeOnSelectionChange(EventHandler value) | Sets the current border setting. |
setBorder(boolean value) | Sets the width of each column in a multicolumn list box. |
setColumnWidth(int value) | Sets the style of the list. |
setDrawMode(int value) | Indicates if the list box should avoid showing partial items. |
setIntegralHeight(boolean value) | Allows you to change the value at the given index. |
setItem(int index, Object item) | Sets the height of an item in an OWNERDRAWFIXED list box. |
setItemHeight(int value) | Allows the user to set all the items in the list box at once by passing in an array with all their values. |
setItems(Object[] value) | Indicates if the list box is multicolumn. |
setMultiColumn(boolean value) | For normal listboxes, indicates if the scroll bar will always be shown on the right side of the list, even if the number of list items is not enough to fill up the entire list. |
setScrollAlwaysVisible(boolean value) | Allows the user to set an item as being selected or not. |
setSelected(int index, boolean value) | Sets the item at the supplied index as being the selected item in the list. |
setSelectedIndex(int index) | Controls how many items in the list box can be selected at a time. |
setSelectionStyle(int value) | When the list box is sorted, all values in the list are sorted alphbaetically. |
setSorted(boolean value) | Enables a list box to recognize and expand tab characters when drawing its strings. |
setUseTabStops(boolean value) |
Creates a basic win32 list box with default values for everything.
Returns index of where the item was inserted.
Adds an item to the list box. The code that adds the item will call toString() on it and inserts that value into the list box. If the sorted property is set to true, the item is properly sorted in the list. The actual index where the item was inserted is returned to the caller.
Adds an event handler for the OnDrawItem event notification. This event is called for list boxes whose drawMode property is set to DrawMode.OWNERDRAWFIXED or DrawMode.OWNERDRAWVARIABLE and contains a Graphics object in which people should paint the item. Duplicates adds are not filtered out.
Adds an event handler for the OnMeasureItem event notification. This event is called for list boxes whose drawMode property is set to DrawMode.OWNERDRAWFIXED or DrawMode.OWNERDRAWVARIABLE and asks the programmer for the size of the given item in the list box. If the DrawMode is OWNERDRAWFIXED, this event is sent only once. Duplicates adds are not filtered out.
Adds an event handler for the OnSelectionChange event notification. This event is sent whenever the selection changes. Duplicates are not filtered out.
Returns index of the item found, or returns ListBox.NOMATCHES if no match is found
Finds the first item in the list that starts with the specified string. The search is case insensitive
Returns an index of the item found, or returns ListBox.NOMATCHES if no match is found.
Finds the first item after the specified index that starts with the specified string. This search is case insensitive.
Returns an index of the item found, or returns ListBox.NOMATCHES if no match is found.
Finds the first item in the list that is the same string as that specified in the findString parameter. The search is still, however, case insensitive.
Returns an index of the item found, or returns ListBox.NOMATCHES if no match is found.
Finds the first item after the speicified index that is the same string as that specified in the findString parameter. The search is still, however, case insensitive.
Returns border setting.
Retrieves the current border setting. If the border is set to true a 3D border is drawn around the list box.
Returns int The width, in pixels, of each column in the list box.
In a multicolumn list box, returns the current width of each column in the list. A value of zero [0] means that Windows will choose a default width for each column.
Returns integer with the style.
Returns the style of the list box. This indicates if the system draws it, or if the user paints each item manually. It also indicates whether items have to be of the same height.
Returns boolean value indicating if only full items will be shown.
Indicates if the list box should avoid showing partial items. If so, only full items will be displayed, and the list box will be resized to prevent partial items from being shown. Otherwise, they will be shown.
Returns an Object handle with the item at that index in the list box.
Returns the item at the given index. All indexes are zero-based.
Returns the number of items in the list box.
Returns a count of the total number of items in the list box.
Returns an integer with the height, in pixels, of an item in the list.
Returns the height of an item in the list box if the drawMode is either NORMAL or OWNERDRAWFIXED. For OWNERDRAWVARIABLE type list boxes, this routine returns the height of the first item. To determine the height of other items, use the other version of this routine.
Returns an integer with the height, in pixels, of the given item in the list.
Returns the height of the given item in an OWNERDRAWVARIABLE style list box. This routine should not be called for fixed-item height style lists.
Returns a rectangle.
Returns a Rectangle object which describes the bounding rectangle around an item in the list.
Returns Object[]. The first item is the 0th element, and the last item in the list is last in the array.
Returns an object array with all the items in the ListBox.
Returns a boolean value indicating whether the list box is multicolumn.
Indicates if the list box is multicolumn or not. If it's multicolumn, the list box uses the columnWidth property to determine how wide to make each column and displays the data horizontally in columns instead of vertically.
Returns int with the height, in pixels, of all items in the list box.
Returns the total height of the items in the list box.
Returns a boolean value indicating whether the scroll bar should always be visible.
For normal list boxes, this indicates if the scroll bar will always be shown on the right side of the list, even if the number of list items is not enough to fill the entire list. By default, Windows will show a scroll bar only when there are enough items to warrant it. For multicolumn list boxes, Windows does not show a horizontal scroll bar. Setting this value indicates that a horizontal scroll bar should be added. There is never a vertical scroll bar.
Returns a boolean value indicating whether it is true or not false.
Indicates whether the item at the supplied index is selected.
Returns an integer.
Returns the index of the currently selected item in the list if there is one. If the value is -1, there is currently no selection. If the value is 0 or greater, the value is the index of the currently selected item. If the MultiSelect property on the list box is true, a non-zero value for this property is the index of the first selection
Returns int [] Array with all the selected indexes.
If multiselection is allowed, returns an array of all items that are currently selected. If in a single selection list box, then the currently selected item is returned in a single element array, or if the selection is not allowed, returns null.
Returns an object with either null or the current selection.
Returns the value of the currently selected item in the list,if there is one. If the value is null, there is currently no selection. If the value is non-null, the value is that of the currently selected item. If the MultiSelect property on the list box is true, a non-null return value for this method is the value of the first item selected.
Returns int with the current value.
Controls how many items in the list box can be selected at a time. Valid values are: SelectionStyle.NONE [0] - No items can be selected in the list. SelectionStyle.ONE [1] - Only one item at a time can be selected. SelectionStyle.MULIT_SIMPLE [2] - More than one item at a time can be selected. SelectionStyle.MULTI_EXTENDED [3] - More than one item at a time can be selected and keyboard characters. such as SHIFT and CTRL can be used to assist in selection.
Returns boolean with the current value.
Indicates if the list box is sorted or not. If set to true, the strings in the list will be sorted alphabetically.
Returns int Index of the topmost visible item.
Retrieves the index of the first visible item in a list box. Initially, the item with index 0 is at the top of the list box, If the list box contents have been scrolled, another item may be at the top.
Returns boolean indicating whether or not the list box will honor tabs.
Enables a list box to recognize and expand tab characters when drawing its strings.
Allows you to add an Item to the ListBox in a location you specify, as opposed to the end of the list. Note that if the sorted property is set to true, values inserted by this method are not property sorted. The
Returns index of item that is under said point, or returns ListBox.NOMATCHES if there is no item in this location.
Returns the index of the item at the given coordinates.
Returns index of item that is at the specified point, or returns ListBox.NOMATCHES if there is no item in this location.
Returns the index of the item at the given coordinates.
Override this to guarantee that the list is refilled when necessary.
Removes all items from the list box. All values and item data are lost.
Removes an individual item from the list box at the supplied index. The item and its values are discarded.
Removes the given handler for the OnDrawItem event. If there are duplicate entries, all are removed.
Removes the given handler for the OnMeasureItem event. If there are duplicate entries, all are removed.
Removes the given handler for the OnSelectionChange event. If there are duplicate entries, all are removed.
Sets the current border setting. If the border is set to true, a three-dimensisonal border is drawn around the list box.
Sets the width of each column in a multicolumn list box. A value of zero [0] means that Windows will pick a width.
Sets the style of the list. This lets users control whether to paint the items themselves [default is not] and whether the items are all the same height [default yes]
Indicates if the list box should avoid showing partial items. If so, only full items will be displayed, and the list box will be resized to prevent partial items from being shown. Otherwise, they will be shown.
Allows you to change the value at the given index. If there is no value at the supplied index, an exception is thrown. Otherwise, the value becomes the newly supplied one
IllegalArgument thrown if the index is not currently assigned a value.
Sets the height of an item in an OWNERDRAWFIXED list box. Users can use this instead of the OnMeasureItem event, which is best used by OWNERDRAWVARIABLE list boxes. This method is ignored by list boxes whose style is DrawMode.NORMAL
Allows the user to set all the items in the list box at once by passing in an array with all their values. All old values in the list box are discarded and lost
Indicates if the list box is multicolumn. If it's multicolumn, the list box uses the columnWidth property to determine how wide to make each column and displays the data horizontally in columns instead of vertically.
For normal listboxes, indicates if the scroll bar will always be shown on the right side of the list, even if the number of list items is not enough to fill up the entire list. By default, Windows will show only a scroll bar when there are enough items to warrant it. For multicolumn list boxes, Windows does not show a horizontal scroll bar at all. Setting this value indicates that a horizontal scroll bar should be added. There is never a vertical scroll bar.
Allows the user to set an item as being selected or not.
Sets the item at the supplied index as being the selected item in the list. If the MultiSelect property is set to true, then this clears all other selections
Returns an integer with the current value.
Controls how many items in the list box can be selected at a time. Valid values are: SelectionStyle.NONE [0] - No items can be selected in the list. SelectionStyle.ONE [1] - Only one item at a time can be selected. SelectionStyle.MULIT_SIMPLE [2] - More than one item at a time can be selected. SelectionStyle.MULTI_EXTENDED [3] - More than one item at a time can be selected, and keyboard characters such as SHIFT and CTRL can be used to assist in selection.
When the list box is sorted, all values in the list are sorted alphbaetically. When the list box is not sorted, the values are displayed in the list in the order they were added.
Enables a list box to recognize and expand tab characters when drawing its strings.