|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.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.
public class ListBoxExample implements EntryPoint {
public void onModuleLoad() {
// Make a new list box, adding a few items to it.
ListBox lb = new ListBox();
lb.addItem("foo");
lb.addItem("bar");
lb.addItem("baz");
lb.addItem("toto");
lb.addItem("tintin");
// Make enough room for all five items (setting this value to 1 turns it
// into a drop-down list).
lb.setVisibleItemCount(5);
// Add it to the root panel.
RootPanel.get().add(lb);
}
}
| Constructor Summary | |
ListBox()
Creates an empty list box. |
|
| Method Summary | |
void |
addChangeListener(ChangeListener listener)
Adds a listener interface to receive change events. |
void |
addItem(java.lang.String item)
Adds an item to the list box. |
void |
addItem(java.lang.String item,
java.lang.String value)
Adds an item to the list box. |
void |
clear()
Removes all items from the list box. |
int |
getItemCount()
Gets the number of items present in the list box. |
java.lang.String |
getItemText(int index)
Gets the text associated with the item at the specified index. |
java.lang.String |
getName()
Gets the widget's name. |
int |
getSelectedIndex()
Gets the currently-selected item. |
java.lang.String |
getValue(int index)
Gets the value associated with the item at a given index. |
int |
getVisibleItemCount()
Gets the number of items that are visible. |
void |
insertItem(java.lang.String item,
int idx)
Inserts an item into the list box. |
void |
insertItem(java.lang.String item,
java.lang.String value,
int beforeIndex)
Inserts an item into the list box. |
boolean |
isItemSelected(int index)
Determines whether an individual list item is selected. |
boolean |
isMultipleSelect()
Gets whether this list allows multiple selection. |
void |
onBrowserEvent(Event event)
Fired whenever a browser event is received. |
void |
removeChangeListener(ChangeListener listener)
Removes a previously added listener interface. |
void |
removeItem(int idx)
Removes the item at the specified index. |
void |
setItemSelected(int index,
boolean selected)
Sets whether an individual list item is selected. |
void |
setMultipleSelect(boolean multiple)
Sets whether this list allows multiple selections |
void |
setName(java.lang.String name)
Sets the widget's name. |
void |
setSelectedIndex(int index)
Sets the currently selected index. |
void |
setValue(int index,
java.lang.String value)
Sets the value associated with the item at a given index. |
void |
setVisibleItemCount(int visibleItems)
Sets the number of items that are visible. |
| Methods inherited from class com.google.gwt.user.client.ui.FocusWidget |
addClickListener, addFocusListener, addKeyboardListener, getTabIndex, isEnabled, removeClickListener, removeFocusListener, removeKeyboardListener, setAccessKey, setEnabled, setFocus, setTabIndex |
| Methods inherited from class com.google.gwt.user.client.ui.Widget |
getParent, isAttached, onAttach, onDetach, onLoad, removeFromParent |
| Methods inherited from class com.google.gwt.user.client.ui.UIObject |
addStyleName, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleName, getTitle, isVisible, isVisible, removeStyleName, setElement, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setTitle, setVisible, setVisible, setWidth, sinkEvents, toString, unsinkEvents |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public ListBox()
| Method Detail |
public void addChangeListener(ChangeListener listener)
SourcesChangeEvents
addChangeListener in interface SourcesChangeEventslistener - the listener interface to addpublic void addItem(java.lang.String item)
item - the text of the item to be added
public void addItem(java.lang.String item,
java.lang.String value)
item - the text of the item to be addedvalue - the item's value, to be submitted if it is part of a
FormPanel.public void clear()
public int getItemCount()
public java.lang.String getItemText(int index)
index - the index of the item whose text is to be retrieved
public java.lang.String getName()
HasName
getName in interface HasNamepublic int getSelectedIndex()
isItemSelected(int)
can be used to query individual items).
-1 if none is selectedpublic java.lang.String getValue(int index)
index - the index of the item to be retrieved
java.lang.IndexOutOfBoundsException - if the index is out of rangepublic int getVisibleItemCount()
public void insertItem(java.lang.String item,
int idx)
item - the text of the item to be insertedidx - the index at which to insert it
public void insertItem(java.lang.String item,
java.lang.String value,
int beforeIndex)
item - the text of the item to be insertedvalue - the item's value, to be submitted if it is part of a
FormPanel.beforeIndex - the index at which to insert itpublic boolean isItemSelected(int index)
index - the index of the item to be tested
true if the item is selectedpublic boolean isMultipleSelect()
true if multiple selection is allowedpublic void onBrowserEvent(Event event)
EventListener
onBrowserEvent in interface EventListeneronBrowserEvent in class FocusWidgetpublic void removeChangeListener(ChangeListener listener)
SourcesChangeEvents
removeChangeListener in interface SourcesChangeEventslistener - the listener interface to removepublic void removeItem(int idx)
idx - the index of the item to be removed
public void setItemSelected(int index,
boolean selected)
index - the index of the item to be selected or unselectedselected - true to select the itempublic void setMultipleSelect(boolean multiple)
multiple - true to allow multiple selectionspublic void setName(java.lang.String name)
HasName
setName in interface HasNamename - the widget's new namepublic void setSelectedIndex(int index)
index - the index of the item to be selected
public void setValue(int index,
java.lang.String value)
FormPanel.
index - the index of the item to be setvalue - the item's new value
java.lang.IndexOutOfBoundsException - if the index is out of rangepublic void setVisibleItemCount(int visibleItems)
visibleItems - the visible item count
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||