java.lang.Object
javax.swing.DefaultListSelectionModel
- All Implemented Interfaces:
Serializable
,Cloneable
,ListSelectionModel
public class DefaultListSelectionModel
extends Object
implements ListSelectionModel, Cloneable, Serializable
Default data model for list selections.
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
.
- Since:
- 1.2
- See Also:
ListSelectionModel
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
Whether or not the lead anchor notification is enabled.protected EventListenerList
The list of listeners.Fields declared in interface javax.swing.ListSelectionModel
MULTIPLE_INTERVAL_SELECTION, SINGLE_INTERVAL_SELECTION, SINGLE_SELECTION
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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 betweenindex0
andindex1
inclusive.void
Change the selection to the empty set.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)
NotifiesListSelectionListeners
that the value of the selection, in the closed intervalfirstIndex
,lastIndex
, has changed.protected void
fireValueChanged(int firstIndex, int lastIndex, boolean isAdjusting)
int
Return the first index argument from the most recent call to setSelectionInterval(), addSelectionInterval() or removeSelectionInterval().int
Return the second index argument from the most recent call to setSelectionInterval(), addSelectionInterval() or removeSelectionInterval().<T extends EventListener>
T[]getListeners(Class<T> listenerType)
Returns an array of all the objects currently registered asFooListener
s upon this model.Returns an array of all the list selection listeners registered on thisDefaultListSelectionModel
.int
Returns the last selected index or -1 if the selection is empty.int
Returns the first selected index or -1 if the selection is empty.int
Returns the current selection mode.boolean
Returnstrue
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
Returns the value of theleadAnchorNotificationEnabled
flag.boolean
isSelectedIndex(int index)
Returns true if the specified index is selected.boolean
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
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 betweenindex0
andindex1
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 betweenindex0
andindex1
inclusive.void
setSelectionMode(int selectionMode)
Sets the selection mode.void
setValueIsAdjusting(boolean isAdjusting)
Sets thevalueIsAdjusting
property, which indicates whether or not upcoming selection changes should be considered part of a single change.