public class DefaultListSelectionModel extends Object implements ListSelectionModel, Cloneable, Serializable
Warning:
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeans™
has been added to the java.beans
package.
Please see XMLEncoder
.
ListSelectionModel
Modifier and Type | Field | Description |
---|---|---|
protected boolean |
leadAnchorNotificationEnabled |
|
protected EventListenerList |
listenerList |
MULTIPLE_INTERVAL_SELECTION, SINGLE_INTERVAL_SELECTION, SINGLE_SELECTION
Constructor | Description |
---|---|
DefaultListSelectionModel() |
Modifier and Type | Method | Description |
---|---|---|
void |
addListSelectionListener(ListSelectionListener l) |
Add a listener to the list that's notified each time a change
to the selection occurs.
|
void |
addSelectionInterval(int index0,
int index1) |
Changes the selection to be the set union of the current selection
and the indices between
index0 and index1 inclusive. |
void |
clearSelection() |
Change the selection to the empty set.
|
Object |
clone() |
Returns a clone of this selection model with the same selection.
|
protected void |
fireValueChanged(boolean isAdjusting) |
Notifies listeners that we have ended a series of adjustments.
|
protected void |
fireValueChanged(int firstIndex,
int lastIndex) |
Notifies
ListSelectionListeners that the value
of the selection, in the closed interval firstIndex ,
lastIndex , has changed. |
protected void |
fireValueChanged(int firstIndex,
int lastIndex,
boolean isAdjusting) |
|
int |
getAnchorSelectionIndex() |
Return the first index argument from the most recent call to
setSelectionInterval(), addSelectionInterval() or removeSelectionInterval().
|
int |
getLeadSelectionIndex() |
Return the second index argument from the most recent call to
setSelectionInterval(), addSelectionInterval() or removeSelectionInterval().
|
<T extends EventListener> |
getListeners(Class<T> listenerType) |
Returns an array of all the objects currently registered as
FooListener s
upon this model. |
ListSelectionListener[] |
getListSelectionListeners() |
Returns an array of all the list selection listeners
registered on this
DefaultListSelectionModel . |
int |
getMaxSelectionIndex() |
Returns the last selected index or -1 if the selection is empty.
|
int |
getMinSelectionIndex() |
Returns the first selected index or -1 if the selection is empty.
|
int |
getSelectionMode() |
Returns the current selection mode.
|
boolean |
getValueIsAdjusting() |
Returns
true if the selection is undergoing a series of changes. |
void |
insertIndexInterval(int index,
int length,
boolean before) |
Insert length indices beginning before/after index.
|
boolean |
isLeadAnchorNotificationEnabled() |
Returns the value of the
leadAnchorNotificationEnabled flag. |
boolean |
isSelectedIndex(int index) |
Returns true if the specified index is selected.
|
boolean |
isSelectionEmpty() |
Returns true if no indices are selected.
|
void |
moveLeadSelectionIndex(int leadIndex) |
Set the lead selection index, leaving all selection values unchanged.
|
void |
removeIndexInterval(int index0,
int index1) |
Remove the indices in the interval index0,index1 (inclusive) from
the selection model.
|
void |
removeListSelectionListener(ListSelectionListener l) |
Remove a listener from the list that's notified each time a
change to the selection occurs.
|
void |
removeSelectionInterval(int index0,
int index1) |
Changes the selection to be the set difference of the current selection
and the indices between
index0 and index1 inclusive. |
void |
setAnchorSelectionIndex(int anchorIndex) |
Set the anchor selection index, leaving all selection values unchanged.
|
void |
setLeadAnchorNotificationEnabled(boolean flag) |
Sets the value of the leadAnchorNotificationEnabled flag.
|
void |
setLeadSelectionIndex(int leadIndex) |
Sets the lead selection index, ensuring that values between the
anchor and the new lead are either all selected or all deselected.
|
void |
setSelectionInterval(int index0,
int index1) |
Changes the selection to be between
index0 and index1
inclusive. |
void |
setSelectionMode(int selectionMode) |
Sets the selection mode.
|
void |
setValueIsAdjusting(boolean isAdjusting) |
Sets the
valueIsAdjusting property, which indicates whether
or not upcoming selection changes should be considered part of a single
change. |
String |
toString() |
Returns a string that displays and identifies this
object's properties.
|
protected EventListenerList listenerList
protected boolean leadAnchorNotificationEnabled
public int getMinSelectionIndex()
getMinSelectionIndex
in interface ListSelectionModel
public int getMaxSelectionIndex()
getMaxSelectionIndex
in interface ListSelectionModel
public boolean getValueIsAdjusting()
true
if the selection is undergoing a series of changes.getValueIsAdjusting
in interface ListSelectionModel
ListSelectionModel.setValueIsAdjusting(boolean)
public int getSelectionMode()
getSelectionMode
in interface ListSelectionModel
ListSelectionModel.setSelectionMode(int)
public void setSelectionMode(int selectionMode)
ListSelectionModel.SINGLE_SELECTION
-
Only one list index can be selected at a time. In this mode,
setSelectionInterval
and addSelectionInterval
are
equivalent, both replacing the current selection with the index
represented by the second argument (the "lead").
ListSelectionModel.SINGLE_INTERVAL_SELECTION
-
Only one contiguous interval can be selected at a time.
In this mode, addSelectionInterval
behaves like
setSelectionInterval
(replacing the current selection),
unless the given interval is immediately adjacent to or overlaps
the existing selection, and can therefore be used to grow it.
ListSelectionModel.MULTIPLE_INTERVAL_SELECTION
-
In this mode, there's no restriction on what can be selected.
setSelectionMode
in interface ListSelectionModel
IllegalArgumentException
- if the selection mode isn't
one of those allowedListSelectionModel.getSelectionMode()
public boolean isSelectedIndex(int index)
isSelectedIndex
in interface ListSelectionModel
public boolean isSelectionEmpty()
isSelectionEmpty
in interface ListSelectionModel
public void addListSelectionListener(ListSelectionListener l)
addListSelectionListener
in interface