javax.swing
public class DefaultListSelectionModel extends Object implements Cloneable, ListSelectionModel, Serializable
The class is organized abstractly as a set of intervals of integers. Each interval indicates an inclusive range of indices in a list -- held by some other object and unknown to this class -- which is considered "selected". There are various accessors for querying and modifying the set of intervals, with simplified forms accepting a single index, representing an interval with only one element.
Field Summary | |
---|---|
protected boolean | leadAnchorNotificationEnabled
controls the range of indices provided in any {@link
ListSelectionEvent} fired by the selectionModel. |
protected EventListenerList | listenerList The list of ListSelectionListeners subscribed to this selection model. |
Method Summary | |
---|---|
void | addListSelectionListener(ListSelectionListener listener)
Adds a listener.
|
void | addSelectionInterval(int index0, int index1)
If the {@link #selectionMode} property is equal to
SINGLE_SELECTION equivalent to calling
setSelectionInterval(index1, index2) ;
If the {@link #selectionMode} property is equal to
SINGLE_INTERVAL_SELECTION and the interval being
added is not adjacent to an already selected interval,
equivalent to setSelectionInterval(index1, index2) .
|
void | clearSelection()
Removes all intervals in the selection set. |
Object | clone()
Returns a clone of this object.
|
protected void | fireValueChanged(boolean isAdjusting)
Fires a {@link ListSelectionEvent} to all the listeners of type {@link
ListSelectionListener} registered with this selection model to
indicate that a series of adjustment has just ended.
|
protected void | fireValueChanged(int firstIndex, int lastIndex)
Fires a {@link ListSelectionEvent} to all the listeners of type {@link
ListSelectionListener} registered with this selection model.
|
protected void | fireValueChanged(int firstIndex, int lastIndex, boolean isAdjusting)
Fires a {@link ListSelectionEvent} to all the listeners of type {@link
ListSelectionListener} registered with this selection model.
|
int | getAnchorSelectionIndex()
Gets the value of the {@link #anchorSelectionIndex} property.
|
int | getLeadSelectionIndex()
Gets the value of the {@link #leadSelectionIndex} property.
|
<T extends EventListener> T[] | getListeners(Class<T> listenerType)
Returns an array of all registerers listeners.
|
ListSelectionListener[] | getListSelectionListeners()
Returns an array of all registerd list selection listeners.
|
int | getMaxSelectionIndex()
Gets the largest index which is currently a member of a selection
interval.
|
int | getMinSelectionIndex()
Gets the smallest index which is currently a member of a selection
interval.
|
int | getSelectionMode()
Returns the selection mode, which is one of {@link #SINGLE_SELECTION},
{@link #SINGLE_INTERVAL_SELECTION} and
{@link #MULTIPLE_INTERVAL_SELECTION}. |
boolean | getValueIsAdjusting()
Gets the value of the {@link #valueIsAdjusting} property.
|
void | insertIndexInterval(int index, int length, boolean before)
Inserts a number of indices either before or after a particular
position in the set of indices. |
boolean | isLeadAnchorNotificationEnabled()
Gets the value of the {@link #leadAnchorNotificationEnabled} property.
|
boolean | isSelectedIndex(int a)
Determines whether a particular index is a member of a selection
interval.
|
boolean | isSelectionEmpty()
Determines whether the selection is empty.
|
void | moveLeadSelectionIndex(int leadIndex)
Moves the lead selection index to leadIndex without
changing the selection values.
|
void | removeIndexInterval(int index0, int index1)
Removes a range from the set of indices. |
void | removeListSelectionListener(ListSelectionListener listener)
Removes a registered listener.
|
void | removeSelectionInterval(int index0, int index1)
Deselects all indices in the inclusive range
[index0,index1] .
|
void | setAnchorSelectionIndex(int index)
Sets the value of the {@link #anchorSelectionIndex} property.
|
void | setLeadAnchorNotificationEnabled(boolean l)
Sets the value of the {@link #leadAnchorNotificationEnabled} property.
|
void | setLeadSelectionIndex(int leadIndex) Sets the value of the {@link #anchorSelectionIndex} property. |
void | setSelectionInterval(int anchor, int lead)
Clears the current selection and marks a given interval as "selected". |
void | setSelectionMode(int mode)
Sets the value of the {@link #selectionMode} property.
|
void | setValueIsAdjusting(boolean v)
Sets the value of the {@link #valueIsAdjusting} property.
|
[A,L]
be the range of indices between {@link
#anchorSelectionIndex} and {@link #leadSelectionIndex} inclusive, and
let [i0,i1]
be the range of indices changed in a given
call which generates a {@link ListSelectionEvent}. Then when this
property is true
, the {@link ListSelectionEvent} contains
the range [A,L] union [i0,i1]
; when false
it
will contain only [i0,i1]
. The default is
true
.
See Also: DefaultListSelectionModel DefaultListSelectionModel
Parameters: listener The listener to add
See Also: DefaultListSelectionModel DefaultListSelectionModel
SINGLE_SELECTION
equivalent to calling
setSelectionInterval(index1, index2)
;
If the {@link #selectionMode} property is equal to
SINGLE_INTERVAL_SELECTION
and the interval being
added is not adjacent to an already selected interval,
equivalent to setSelectionInterval(index1, index2)
.
Otherwise adds the range [index0, index1]
to the selection interval set.
Parameters: index0 The beginning of the range of indices to select index1 The end of the range of indices to select
See Also: DefaultListSelectionModel DefaultListSelectionModel
listenerList
don't gets duplicated.
Returns: the cloned object
Throws: CloneNotSupportedException if an error occurs
Parameters: isAdjusting true
if this is the final change
in a series of adjustments, false/code> otherwise
Parameters: firstIndex The low index of the changed range lastIndex The high index of the changed range
Parameters: firstIndex The low index of the changed range lastIndex The high index of the changed range isAdjusting Whether this change is part of a seqence of adjustments made to the selection, such as during interactive scrolling
Returns: The current property value
See Also: DefaultListSelectionModel
Returns: The current property value
See Also: DefaultListSelectionModel
Parameters: listenerType The type of listener to retrieve
Returns: The array
Since: 1.3
See Also: DefaultListSelectionModel
Returns: the array
Since: 1.4
See Also: DefaultListSelectionModel DefaultListSelectionModel DefaultListSelectionModel
Returns: The greatest integer i
such that i >=
0
and i
is a member of a selected interval, or
-1
if there are no selected intervals
See Also: DefaultListSelectionModel
Returns: The least integer i
such that i >=
0
and i
is a member of a selected interval, or
-1
if there are no selected intervals
See Also: DefaultListSelectionModel
Returns: The selection mode.
See Also: DefaultListSelectionModel
Returns: The current property value
See Also: DefaultListSelectionModel
Parameters: index The position to insert indices at length The number of indices to insert before Indicates whether to insert the indices before the index or after it
Returns: The current property value
See Also: DefaultListSelectionModel
Parameters: a The index to search for
Returns: true
if the index is a member of a selection interval,
otherwise false
Returns: true
if the selection is empty, otherwise
false
leadIndex
without
changing the selection values.
If leadAnchorNotificationEnabled is true, send a notification covering the
old and new lead cells.
Parameters: leadIndex the new lead selection index
Since: 1.5
Parameters: index0 The first index to remove (inclusive) index1 The last index to remove (inclusive)
Parameters: listener The listener to remove
See Also: DefaultListSelectionModel DefaultListSelectionModel
[index0,index1]
.
Parameters: index0 The beginning of the range of indices to deselect index1 The end of the range of indices to deselect
See Also: DefaultListSelectionModel DefaultListSelectionModel
Parameters: index The new property value
See Also: DefaultListSelectionModel
Parameters: l The new property value
See Also: DefaultListSelectionModel
Sets the value of the {@link #anchorSelectionIndex} property. As a
side effect, alters the selection status of two ranges of indices. Let
OL
be the old lead selection index, NL
be
the new lead selection index, and A
be the anchor
selection index. Then if A
is a valid selection index,
one of two things happens depending on the seleciton status of
A
:
isSelectedIndex(A) == true
: set [A,OL]
to deselected, then set [A,NL]
to
selected.isSelectedIndex(A) == false
: set [A,OL]
to selected, then set [A,NL]
to
deselected.This method generates at most a single {@link ListSelectionEvent} despite changing multiple ranges. The range of values provided to the {@link ListSelectionEvent} includes only the minimum range of values which changed selection status between the beginning and end of the method.
Parameters: leadIndex The new property value
See Also: DefaultListSelectionModel
SINGLE_SELECTION
only the
index index2
is selected.
Parameters: anchor the anchor selection index. lead the lead selection index.
Parameters: mode The new value of the property
Parameters: v The new property value
See Also: DefaultListSelectionModel