nextapp.echo
Class ListBox

java.lang.Object
  extended by nextapp.echo.AbstractComponent
      extended by nextapp.echo.ListBox
All Implemented Interfaces:
java.io.Serializable, Component, ToolTipSupport

public class ListBox
extends AbstractComponent
implements ToolTipSupport

A component that allows the selection of one or more displayed items.

See Also:
Serialized Form

Field Summary
static java.lang.String CELL_RENDERER_CHANGED_PROPERTY
           
static java.lang.String CSS_CLASS_CHANGED_PROPERTY
           
static java.lang.String LIST_DATA_CHANGED_PROPERTY
           
static java.lang.String LIST_SELECTION_CHANGED_PROPERTY
           
static int PERCENT_UNITS
          A constant for units-defining properties that represent percent-based units.
static int PIXEL_UNITS
          A constant for units-defining properties that represent pixel-based units.
static java.lang.String SELECTION_MODE_CHANGED_PROPERTY
           
static java.lang.String SELECTION_MODEL_CHANGED_PROPERTY
           
static java.lang.String STYLE_VISIBLE_ROW_COUNT
          A style constant for the Visible Row Count property.
static java.lang.String STYLE_WIDTH
          A style constant for the Width property.
static java.lang.String STYLE_WIDTH_UNITS
          A style constant for the Width Units property.
static java.lang.String VISIBLE_ROW_COUNT_CHANGED_PROPERTY
           
static java.lang.String WIDTH_CHANGED_PROPERTY
           
static java.lang.String WIDTH_UNITS_CHANGED_PROPERTY
           
 
Fields inherited from interface nextapp.echo.ToolTipSupport
TOOL_TIP_TEXT_CHANGED_PROPERTY
 
Fields inherited from interface nextapp.echo.Component
BACKGROUND_CHANGED_PROPERTY, CHILDREN_CHANGED_PROPERTY, ENABLED_CHANGED_PROPERTY, FONT_CHANGED_PROPERTY, FOREGROUND_CHANGED_PROPERTY, IDENTIFIER_CHANGED_PROPERTY, LOCALE_CHANGED_PROPERTY, MODEL_CHANGED_PROPERTY, SELECTABLE_CHANGED_PROPERTY, STYLE_BACKGROUND, STYLE_FONT, STYLE_FOREGROUND, UPDATE_PROPERTY, VISIBLE_CHANGED_PROPERTY
 
Constructor Summary
ListBox()
          Creates an empty ListBox.
ListBox(ListModel model)
          Creates a ListBox with the given data model.
ListBox(java.lang.Object[] elements)
          Creates a ListBox with a default model populated with the given array of elements.
 
Method Summary
 void addActionListener(ActionListener l)
          Adds an ActionListener to the button.
 void applyStyle(Style style)
          Sets stylistic properties of this component based on a Style object.
 void clearSelection()
          Deselects all items.
 void doAction(boolean doubleClick)
           
 void fireActionPerformed(ActionEvent e)
          Notifies all listeners that have registered for this event type.
 ListCellRenderer getCellRenderer()
          Returns the renderer for items.
 java.lang.String getCssClass()
           
 int getMaxSelectedIndex()
          Returns the maximum selected index.
 int getMinSelectedIndex()
          Returns the minimum selected index.
 ListModel getModel()
          Returns the model.
 int getSelectedIndex()
          Returns the selected index.
 int[] getSelectedIndices()
          Returns all selected indices.
 java.lang.Object getSelectedValue()
          Returns the selected item.
 java.lang.Object[] getSelectedValues()
          Returns all selected items.
 int getSelectionMode()
          Returns the selection mode.
 ListSelectionModel getSelectionModel()
          Returns the selection model.
 java.lang.String getToolTipText()
          Returns the default tool tip text.
 int getVisibleRowCount()
          Returns the number of rows that will be simultaneously displayed.
 int getWidth()
          Returns the width of the ListBox.
 int getWidthUnits()
          Returns the width units of the ListBox.
 boolean hasActionListeners()
           
 boolean isAsync()
           
 boolean isDoubleClickActionListeners()
           
 boolean isNoTabStop()
           
 boolean isSelectedIndex(int index)
          Determines whether an index is selected.
 void removeActionListener(ActionListener l)
          Removes an ActionListener from the button.
 void setAsync(boolean async)
           
 void setCellRenderer(ListCellRenderer newValue)
          Sets the renderer for items.
 void setCssClass(java.lang.String newValue)
           
 void setDoubleClickActionListeners(boolean doubleClickActionListeners)
           
 void setModel(ListModel newValue)
          Sets the model.
 void setNoTabStop(boolean noTabStop)
           
 void setSelectedIndex(int index)
          Selects only the given index.
 void setSelectedIndex(int index, boolean selected)
          Sets the selection state of the given index.
 void setSelectedIndices(int[] indices)
          Selects an array of indices.
 void setSelectionMode(int newValue)
          Sets the selection mode.
 void setSelectionModel(ListSelectionModel newValue)
          Sets the selection model.
 void setToolTipText(java.lang.String newValue)
          Sets the default tool tip text.
 void setVisibleRowCount(int newValue)
          Sets the number of rows that will be simultaneously displayed.
 void setWidth(int newValue)
          Sets the width of the ListBox.
 void setWidthUnits(int newValue)
          Sets the width units of the ListBox.
 
Methods inherited from class nextapp.echo.AbstractComponent
add, add, addHierarchyListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getClientId, getComponent, getComponentCount, getComponents, getEchoInstance, getFont, getForeground, getIdentifier, getListenerList, getLocale, getParent, indexOf, init, isAncestorOf, isDifferent, isEnabled, isFocused, isRecursivelyVisible, isRegistered, isSelectableForScriptRecorder, isShowing, isVisible, processHierarchyEvent, remove, remove, removeAll, removeHierarchyListener, removePropertyChangeListener, setBackground, setClientId, setEnabled, setFocused, setFont, setForeground, setIdentifier, setLocale, setParent, setRegistered, setSelectableForScriptRecorder, setVisible, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PIXEL_UNITS

public static final int PIXEL_UNITS
A constant for units-defining properties that represent pixel-based units.

See Also:
Constant Field Values

PERCENT_UNITS

public static final int PERCENT_UNITS
A constant for units-defining properties that represent percent-based units.

See Also:
Constant Field Values

STYLE_WIDTH

public static final java.lang.String STYLE_WIDTH
A style constant for the Width property. Values of this key must be of type java.lang.Integer.

See Also:
Constant Field Values

STYLE_WIDTH_UNITS

public static final java.lang.String STYLE_WIDTH_UNITS
A style constant for the Width Units property. Values of this key must be of type java.lang.Integer.

See Also:
Constant Field Values

STYLE_VISIBLE_ROW_COUNT

public static final java.lang.String STYLE_VISIBLE_ROW_COUNT
A style constant for the Visible Row Count property. Values of this key must be of type java.lang.Integer.

See Also:
Constant Field Values

CELL_RENDERER_CHANGED_PROPERTY

public static final java.lang.String CELL_RENDERER_CHANGED_PROPERTY
See Also:
Constant Field Values

LIST_DATA_CHANGED_PROPERTY

public static final java.lang.String LIST_DATA_CHANGED_PROPERTY
See Also:
Constant Field Values

LIST_SELECTION_CHANGED_PROPERTY

public static final java.lang.String LIST_SELECTION_CHANGED_PROPERTY
See Also:
Constant Field Values

SELECTION_MODEL_CHANGED_PROPERTY

public static final java.lang.String SELECTION_MODEL_CHANGED_PROPERTY
See Also:
Constant Field Values

VISIBLE_ROW_COUNT_CHANGED_PROPERTY

public static final java.lang.String VISIBLE_ROW_COUNT_CHANGED_PROPERTY
See Also:
Constant Field Values

WIDTH_CHANGED_PROPERTY

public static final java.lang.String WIDTH_CHANGED_PROPERTY
See Also:
Constant Field Values

WIDTH_UNITS_CHANGED_PROPERTY

public static final java.lang.String WIDTH_UNITS_CHANGED_PROPERTY
See Also:
Constant Field Values

SELECTION_MODE_CHANGED_PROPERTY

public static final java.lang.String SELECTION_MODE_CHANGED_PROPERTY
See Also:
Constant Field Values

CSS_CLASS_CHANGED_PROPERTY

public static final java.lang.String CSS_CLASS_CHANGED_PROPERTY
See Also:
Constant Field Values
Constructor Detail

ListBox

public ListBox()
Creates an empty ListBox.


ListBox

public ListBox(ListModel model)
Creates a ListBox with the given data model.

Parameters:
model - The ListModel for this ListBox.

ListBox

public ListBox(java.lang.Object[] elements)
Creates a ListBox with a default model populated with the given array of elements.

Parameters:
elements - An array of elements that will initially populate this ListBox.
Method Detail

applyStyle

public void applyStyle(Style style)
Description copied from interface: Component
Sets stylistic properties of this component based on a Style object. The version of this method in Component will set foreground and background colors and the font from the style if they are present. Components should override this method if they allow more properties to be set from a style object, and should call super.applyStyle() if necessary.

Specified by:
applyStyle in interface Component
Overrides:
applyStyle in class AbstractComponent
Parameters:
style - The style object from which to retrieve properties for this Component.
See Also:
Component.applyStyle(Style)

clearSelection

public void clearSelection()
Deselects all items.


getCellRenderer

public ListCellRenderer getCellRenderer()
Returns the renderer for items.

Returns:
The renderer for items.

getMaxSelectedIndex

public int getMaxSelectedIndex()
Returns the maximum selected index.

Returns:
the maximum selected index.

getMinSelectedIndex

public int getMinSelectedIndex()
Returns the minimum selected index.

Returns:
The minimum selected index.

getModel

public ListModel getModel()
Returns the model.

Returns:
The model.

getSelectedIndex

public int getSelectedIndex()
Returns the selected index. This method is used for ListBoxes where the selectionMode property is set to ListSelectionModel.SINGLE_SELECT. In the event multiple selection is enabled, this method will return the lowest selected index.

Returns:
The selected index.

getSelectedValue

public java.lang.Object getSelectedValue()
Returns the selected item. This method is used for ListBoxes where the selectionMode property is set to ListSelectionModel.SINGLE_SELECT. In the event multiple selection is enabled, this method will return the item at the lowest selected index.

Returns:
The selected item.

getSelectedIndices

public int[] getSelectedIndices()
Returns all selected indices.

Returns:
An array of all selected indices.

getSelectedValues

public java.lang.Object[] getSelectedValues()
Returns all selected items.

Returns:
An array of all the selected items.

getSelectionMode

public int getSelectionMode()
Returns the selection mode.

Returns:
The selection mode, one of the following values:
  • ListSelectionModel.SINGLE_SELECTION: only one list element may be selected.
  • ListSelectionModel.MULTIPLE_SELECTION: multiple list elements may be selected.

getSelectionModel

public ListSelectionModel getSelectionModel()
Returns the selection model.

Returns:
The selection model.

getToolTipText

public java.lang.String getToolTipText()
Description copied from interface: ToolTipSupport
Returns the default tool tip text.

Specified by:
getToolTipText in interface ToolTipSupport
Returns:
The tool tip text.
See Also:
ToolTipSupport.getToolTipText()

getVisibleRowCount

public int getVisibleRowCount()
Returns the number of rows that will be simultaneously displayed.

Returns:
The number of rows that will be simultaneously displayed.

getWidth

public int getWidth()
Returns the width of the ListBox.

Returns:
The width of the ListBox.

getWidthUnits

public int getWidthUnits()
Returns the width units of the ListBox.

Returns:
The width units of the ListBox, one of the following values:
  • PIXEL_UNITS (the default)
  • PERCENT_UNITS

isSelectedIndex

public boolean isSelectedIndex(int index)
Determines whether an index is selected.

Parameters:
index - The index to test for selection.
Returns:
True if the given index is selected.

setCellRenderer

public void setCellRenderer(ListCellRenderer newValue)
Sets the renderer for items.

Parameters:
newValue - The new renderer for items.

setModel

public void setModel(ListModel newValue)
Sets the model.

Parameters:
newValue - The new model.

setSelectedIndex

public void setSelectedIndex(int index)
Selects only the given index.

Parameters:
index - The index to select.

setSelectedIndex

public void setSelectedIndex(int index,
                             boolean selected)
Sets the selection state of the given index.

Parameters:
index - The index to select.

setSelectedIndices

public void setSelectedIndices(int[] indices)
Selects an array of indices.

Parameters:
indices - The indices to be selected.

setSelectionMode

public void setSelectionMode(int newValue)
Sets the selection mode.

Parameters:
newValue - The selection mode, one of the following values:
  • ListSelectionModel.SINGLE_SELECTION: only one list element may be selected.
  • ListSelectionModel.MULTIPLE_SELECTION: multiple list elements may be selected.

setSelectionModel

public void setSelectionModel(ListSelectionModel newValue)
Sets the selection model.

Parameters:
newValue - The new selection model.

setToolTipText

public void setToolTipText(java.lang.String newValue)
Description copied from interface: ToolTipSupport
Sets the default tool tip text.

Specified by:
setToolTipText in interface ToolTipSupport
Parameters:
newValue - The new tool tip text.
See Also:
ToolTipSupport.setToolTipText(String)

setVisibleRowCount

public void setVisibleRowCount(int newValue)
Sets the number of rows that will be simultaneously displayed. The default value of this property is 8.

Parameters:
newValue - The number of rows that will be simultaneously displayed.

setWidth

public void setWidth(int newValue)
Sets the width of the ListBox.

Parameters:
newValue - The new width.

setWidthUnits

public void setWidthUnits(int newValue)
Sets the width units of the ListBox.

Parameters:
newValue - The new width units, one of the following values:
  • PIXEL_UNITS (the default)
  • PERCENT_UNITS

hasActionListeners

public boolean hasActionListeners()

addActionListener

public void addActionListener(ActionListener l)
Adds an ActionListener to the button.

Parameters:
l - The ActionListener to be added.

removeActionListener

public void removeActionListener(ActionListener l)
Removes an ActionListener from the button.

Parameters:
l - The ActionListener to be removed.

fireActionPerformed

public void fireActionPerformed(ActionEvent e)
Notifies all listeners that have registered for this event type.

Parameters:
e - The ActionEvent to send.

doAction

public void doAction(boolean doubleClick)

isDoubleClickActionListeners

public boolean isDoubleClickActionListeners()

setDoubleClickActionListeners

public void setDoubleClickActionListeners(boolean doubleClickActionListeners)

isAsync

public boolean isAsync()

setAsync

public void setAsync(boolean async)

isNoTabStop

public boolean isNoTabStop()

setNoTabStop

public void setNoTabStop(boolean noTabStop)

getCssClass

public java.lang.String getCssClass()

setCssClass

public void setCssClass(java.lang.String newValue)