java.lang.Object | ||||
↳ | com.google.gwt.user.client.ui.UIObject | |||
↳ | com.google.gwt.user.client.ui.Widget | |||
↳ | com.google.gwt.user.client.ui.FocusWidget | |||
↳ | com.google.gwt.user.client.ui.ListBox |
A widget that presents a list of choices to the user, either as a list box or as a drop-down list.
setDirectionEstimator(boolean)
,
and is off by default.
The items of a ListBox element are laid out in <g:item> elements.
Each item contains text that will be added to the list of available
items that will be shown, either in the drop down or list. (Note that
the tags of the item elements are not capitalized. This is meant to
signal that the item is not a runtime object, and so cannot have a
ui:field
attribute.) It is also possible to explicitly
specify item's value using value attribute as shown below.
For example:
<g:ListBox> <g:item> first </g:item> <g:item value='2'> second </g:item> </g:ListBox>
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
com.google.gwt.user.client.ui.UIObject
|
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
DEFAULT_DIRECTION_ESTIMATOR |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates an empty list box in single selection mode.
| |||||||||||
Creates an empty list box.
|
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
This constructor may be used by subclasses to explicitly use an existing
element.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds a
ChangeEvent handler. | |||||||||||
This method is deprecated.
Use
addChangeHandler(ChangeHandler) instead
| |||||||||||
Adds an item to the list box.
| |||||||||||
Adds an item to the list box, specifying its direction.
| |||||||||||
Adds an item to the list box, specifying its direction and an initial value
for the item.
| |||||||||||
Adds an item to the list box, specifying an initial value for the item.
| |||||||||||
Removes all items from the list box.
| |||||||||||
Returns the
DirectionEstimator object. | |||||||||||
Gets the number of items present in the list box.
| |||||||||||
Gets the text associated with the item at the specified index.
| |||||||||||
Gets the widget's name.
| |||||||||||
Gets the currently-selected item.
| |||||||||||
Gets the value associated with the item at a given index.
| |||||||||||
Gets the number of items that are visible.
| |||||||||||
Inserts an item into the list box, specifying its direction and an initial
value for the item.
| |||||||||||
Inserts an item into the list box.
| |||||||||||
Inserts an item into the list box, specifying its direction.
| |||||||||||
Inserts an item into the list box, specifying an initial value for the
item.
| |||||||||||
Determines whether an individual list item is selected.
| |||||||||||
Gets whether this list allows multiple selection.
| |||||||||||
This method is deprecated.
Use the
removeHandler()
method on the object returned by addChangeHandler(ChangeHandler) instead
| |||||||||||
Removes the item at the specified index.
| |||||||||||
Sets the
DirectionEstimator object.
Note: this does not affect the direction of already-existing content. | |||||||||||
Toggles on / off direction estimation.
See note at
setDirectionEstimator(com.google.gwt.i18n.shared.DirectionEstimator)
| |||||||||||
Sets whether an individual list item is selected.
| |||||||||||
Sets the text associated with the item at a given index.
| |||||||||||
Sets the text associated with the item at a given index.
| |||||||||||
This method is deprecated.
use
ListBox(boolean) instead
| |||||||||||
Sets the widget's name.
| |||||||||||
Sets the currently selected index.
| |||||||||||
Sets the value associated with the item at a given index.
| |||||||||||
Sets the number of items that are visible.
| |||||||||||
Creates a ListBox widget that wraps an existing <select> element.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Affected Elements:
|
Creates an empty list box in single selection mode.
Creates an empty list box. The preferred way to enable multiple selections
is to use this constructor rather than setMultipleSelect(boolean)
.
isMultipleSelect | specifies if multiple selection is enabled |
---|
This constructor may be used by subclasses to explicitly use an existing element. This element must be a <select> element.
element | the element to be used |
---|
Adds a ChangeEvent
handler.
handler | the change handler |
---|
HandlerRegistration
used to remove this handler
This method is deprecated.
Use addChangeHandler(ChangeHandler)
instead
Adds a listener interface to receive change events.
listener | the listener interface to add |
---|
Adds an item to the list box. This method has the same effect as
addItem(item, item)
item | the text of the item to be added |
---|
Adds an item to the list box, specifying its direction. This method has the same effect as
addItem(item, dir, item)
item | the text of the item to be added |
---|---|
dir | the item's direction |
Adds an item to the list box, specifying its direction and an initial value for the item.
item | the text of the item to be added |
---|---|
dir | the item's direction |
value | the item's value, to be submitted if it is part of a
FormPanel ; cannot be null
|
Adds an item to the list box, specifying an initial value for the item.
item | the text of the item to be added |
---|---|
value | the item's value, to be submitted if it is part of a
FormPanel ; cannot be null
|
Removes all items from the list box.
Gets the number of items present in the list box.
Gets the text associated with the item at the specified index.
index | the index of the item whose text is to be retrieved |
---|
IndexOutOfBoundsException | if the index is out of range |
---|
Gets the currently-selected item. If multiple items are selected, this
method will return the first selected item (isItemSelected(int)
can be used to query individual items).
-1
if none is selected
Gets the value associated with the item at a given index.
index | the index of the item to be retrieved |
---|
IndexOutOfBoundsException | if the index is out of range |
---|
Gets the number of items that are visible. If only one item is visible, then the box will be displayed as a drop-down list.
Inserts an item into the list box, specifying its direction and an initial value for the item. If the index is less than zero, or greater than or equal to the length of the list, then the item will be appended to the end of the list.
item | the text of the item to be inserted |
---|---|
dir | the item's direction. If null , the item is displayed in
the widget's overall direction, or, if a direction estimator has
been set, in the item's estimated direction. |
value | the item's value, to be submitted if it is part of a
FormPanel . |
index | the index at which to insert it |
Inserts an item into the list box. Has the same effect as
insertItem(item, item, index)
item | the text of the item to be inserted |
---|---|
index | the index at which to insert it |
Inserts an item into the list box, specifying its direction. Has the same effect as
insertItem(item, dir, item, index)
item | the text of the item to be inserted |
---|---|
dir | the item's direction |
index | the index at which to insert it |
Inserts an item into the list box, specifying an initial value for the item. Has the same effect as
insertItem(item, null, value, index)
item | the text of the item to be inserted |
---|---|
value | the item's value, to be submitted if it is part of a
FormPanel . |
index | the index at which to insert it |
Determines whether an individual list item is selected.
index | the index of the item to be tested |
---|
true
if the item is selectedIndexOutOfBoundsException | if the index is out of range |
---|
Gets whether this list allows multiple selection.
true
if multiple selection is allowed
This method is deprecated.
Use the removeHandler()
method on the object returned by addChangeHandler(ChangeHandler)
instead
Removes a previously added listener interface.
listener | the listener interface to remove |
---|
Removes the item at the specified index.
index | the index of the item to be removed |
---|
IndexOutOfBoundsException | if the index is out of range |
---|
Sets the DirectionEstimator
object.
Note: this does not affect the direction of already-existing content.
directionEstimator | The {code DirectionEstimator} to be set. null means turning off direction estimation.
|
---|
Toggles on / off direction estimation.
See note at
setDirectionEstimator(com.google.gwt.i18n.shared.DirectionEstimator)
enabled | Whether to enable direction estimation. If true ,
sets the DirectionEstimator object to a default
DirectionEstimator .
|
---|
Sets whether an individual list item is selected.
Note that setting the selection programmatically does not cause
the onChange(ChangeEvent)
event to be fired.
index | the index of the item to be selected or unselected |
---|---|
selected | true to select the item |
IndexOutOfBoundsException | if the index is out of range |
---|
Sets the text associated with the item at a given index.
index | the index of the item to be set |
---|---|
text | the item's new text |
IndexOutOfBoundsException | if the index is out of range |
---|
Sets the text associated with the item at a given index.
index | the index of the item to be set |
---|---|
text | the item's new text |
dir | the item's direction. |
IndexOutOfBoundsException | if the index is out of range |
---|
This method is deprecated.
use ListBox(boolean)
instead
Sets whether this list allows multiple selections. NOTE: The preferred
way of enabling multiple selections in a list box is by using the
ListBox(boolean)
constructor. Using this method can spuriously
fail on Internet Explorer 6.0.
multiple | true to allow multiple selections |
---|
Sets the currently selected index.
After calling this method, only the specified item in the list will remain
selected. For a ListBox with multiple selection enabled, see
setItemSelected(int, boolean)
to select multiple items at a time.
Note that setting the selected index programmatically does not
cause the onChange(ChangeEvent)
event to be fired.
index | the index of the item to be selected |
---|
Sets the value associated with the item at a given index. This value can be
used for any purpose, but is also what is passed to the server when the
list box is submitted as part of a FormPanel
.
index | the index of the item to be set |
---|---|
value | the item's new value; cannot be null |
IndexOutOfBoundsException | if the index is out of range |
---|
Sets the number of items that are visible. If only one item is visible, then the box will be displayed as a drop-down list.
visibleItems | the visible item count |
---|
Creates a ListBox widget that wraps an existing <select> element.
This element must already be attached to the document. If the element is
removed from the document, you must call
detachNow(Widget)
.
element | the element to be wrapped |
---|
Affected Elements:
baseID | the base ID used by the main element |
---|