A component that allows the user to select one or more objects from a
list.
The JList does not provide scrolling capability. The
JList is normally inserted into a JScrollPane to provide scrolling.
addListSelectionListener
public void addListSelectionListener(ListSelectionListener il_)
Register an ListSelectionListener object for this component.
The listener is notified each time a change to the selection occurs.
addSelectionInterval
public void addSelectionInterval(int index0_,
int index1_)
Sets the selection to be the set union between the current
selection and the specified interval between index0_ and index1_
(inclusive).
clearSelection
public void clearSelection()
Clears the selection. After this isSelectionEmpty()
will return true.
debug
public void debug(int level_)
Outputs a textual description of this component to stderr.
- debug in interface Component
draw
public void draw()
Draws this component. Overrides draw() in Component.
- draw in interface JComponent
ensureIndexIsVisible
public void ensureIndexIsVisible(int index_)
Make the specified item visible (by scrolling the list up or down).
This method does not do anything unless the JList is in a JViewport.
Note that the list is not redrawn by this method; the redrawing is
done by the JScrollPane (that is registered as a ScrollListener).
getMaxSelectionIndex
public int getMaxSelectionIndex()
Returns the highest selected item index.
getMinSelectionIndex
public int getMinSelectionIndex()
Returns the lowest selected item index.
getModel
public ListModel getModel()
Returns the data model that holds the list of items displayed by this
JList.
getSelectedIndex
public int getSelectedIndex()
Get the first selected index, or -1 if there is no selected index.
getSelectedIndices
public int[] getSelectedIndices()
Returns an array of the selected indices. The indices are
sorted in increasing index order.
getSelectedValue
public Object getSelectedValue()
Get the first selected item on this list, or null
if the selection is empty.
getSelectedValues
public Object[] getSelectedValues()
Returns an array of the selected values. The objects are
sorted in increasing index order.
getSelectionMode
public int getSelectionMode()
Determines whether this list allows multiple selections.
getSelectionModel
public ListSelectionModel getSelectionModel()
Returns the list's implementation of ListSelectionModel.
getVisibleRowCount
public int getVisibleRowCount()
isIndexSelected
public boolean isIndexSelected(int index_)
Determines if the specified item in this scrolling list is selected.
removeListSelectionListener
public void removeListSelectionListener(ListSelectionListener listener_)
Remove the specified ListSelectionListener from the list of listeners
that will be notified when the selection changes.
removeSelectionInterval
public void removeSelectionInterval(int index0_,
int index1_)
Sets the selection to be the set difference between the current
selection and the specified interval between index0_ and index1_
(inclusive).
setColumns
public void setColumns(int cols_)
Set the number of columns INSIDE the list.
setListData
public void setListData(Object[] listData_)
Constructs a ListModel from an array of Objects and then applies
setModel to it.
setListData
public void setListData(Vector listData_)
Constructs a ListModel from a Vector and then applies setModel to it.
setModel
public void setModel(ListModel model_)
Sets the model that represents the "contents" of the list, and
clears the selection.
setSelectedIndex
public void setSelectedIndex(int index_)
Select the item at the specified index. Note that this method
does not redraw the JList.
setSelectionMode
public void setSelectionMode(int mode_)
Sets the flag that determines whether this list allows multiple
selections.
mode_
- the selection mode. Allowed values are:
- ListSelectionModel.SINGLE_SELECTION. Only one list index
can be selected at a time.
- ListSelectionModel.SINGLE_INTERVAL_SELECTION.
- ListSelectionModel.MULTIPLE_INTERVAL_SELECTION. Any number
of list items can be selected simultaneously.
setSelectionModel
public void setSelectionModel(ListSelectionModel model_)
Sets the selection model of the JList to an implementation
of the ListSelectionModel interface.
setVisibleRowCount
public void setVisibleRowCount(int rows_)
Set the maximum number of rows that can be displayed at a time
by the JScrollPane which contains this JList.