javax.swing
Class DefaultListSelectionModel
- Cloneable, ListSelectionModel, Serializable
The default implementation of
ListSelectionModel
,
which is used by
JList
and
similar classes to manage the selection status of a number of data
elements.
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.
void | addListSelectionListener(ListSelectionListener listener) - Adds a listener.
|
void | addSelectionInterval(int index0, int index1) - If the
selectionMode property is equal to
SINGLE_SELECTION equivalent to calling
setSelectionInterval(index1, index2) ;
If the 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.
|
| extends EventListener> T[] getListeners(Class listenerType) - Returns an array of all registerers listeners.
|
protected void | fireValueChanged(boolean isAdjusting) - Fires a
ListSelectionEvent to all the listeners of type 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
ListSelectionEvent to all the listeners of type ListSelectionListener registered with this selection model.
|
protected void | fireValueChanged(int firstIndex, int lastIndex, boolean isAdjusting) - Fires a
ListSelectionEvent to all the listeners of type ListSelectionListener registered with this selection model.
|
int | getAnchorSelectionIndex() - Gets the value of the
anchorSelectionIndex property.
|
int | getLeadSelectionIndex() - Gets the value of the
leadSelectionIndex property.
|
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
ListSelectionModel.SINGLE_SELECTION ,
ListSelectionModel.SINGLE_INTERVAL_SELECTION and
ListSelectionModel.MULTIPLE_INTERVAL_SELECTION .
|
boolean | getValueIsAdjusting() - Gets the value of the
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
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
anchorSelectionIndex property.
|
void | setLeadAnchorNotificationEnabled(boolean l) - Sets the value of the
leadAnchorNotificationEnabled property.
|
void | setLeadSelectionIndex(int leadIndex) - Sets the value of the
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
selectionMode property.
|
void | setValueIsAdjusting(boolean v) - Sets the value of the
valueIsAdjusting property.
|
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
addSelectionInterval
public void addSelectionInterval(int index0,
int index1)
If the
selectionMode
property is equal to
SINGLE_SELECTION
equivalent to calling
setSelectionInterval(index1, index2)
;
If the
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.
- addSelectionInterval in interface ListSelectionModel
index0
- The beginning of the range of indices to selectindex1
- The end of the range of indices to select
extends EventListener> T[] getListeners
public extends EventListener> T[] getListeners(Class listenerType)
Returns an array of all registerers listeners.
listenerType
- The type of listener to retrieve
fireValueChanged
protected void fireValueChanged(boolean isAdjusting)
isAdjusting
- true
if this is the final change
in a series of adjustments, false/code> otherwise
fireValueChanged
protected void fireValueChanged(int firstIndex,
int lastIndex)
firstIndex
- The low index of the changed rangelastIndex
- The high index of the changed range
fireValueChanged
protected void fireValueChanged(int firstIndex,
int lastIndex,
boolean isAdjusting)
firstIndex
- The low index of the changed rangelastIndex
- The high index of the changed rangeisAdjusting
- Whether this change is part of a seqence of adjustments
made to the selection, such as during interactive scrolling
getMaxSelectionIndex
public int getMaxSelectionIndex()
Gets the largest index which is currently a member of a selection
interval.
- getMaxSelectionIndex in interface ListSelectionModel
- 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
getMinSelectionIndex
public int getMinSelectionIndex()
Gets the smallest index which is currently a member of a selection
interval.
- getMinSelectionIndex in interface ListSelectionModel
- 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
insertIndexInterval
public 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. Renumbers all indices after the
inserted range. The new indices in the inserted range are not
selected. This method is typically called to synchronize the selection
model with an inserted range of elements in a
ListModel
.
- insertIndexInterval in interface ListSelectionModel
index
- The position to insert indices atlength
- The number of indices to insertbefore
- Indicates whether to insert the indices before the index
or after it
isSelectedIndex
public boolean isSelectedIndex(int a)
Determines whether a particular index is a member of a selection
interval.
- isSelectedIndex in interface ListSelectionModel
a
- The index to search for
true
if the index is a member of a selection interval,
otherwise false
moveLeadSelectionIndex
public void moveLeadSelectionIndex(int leadIndex)
Moves the lead selection index to leadIndex
without
changing the selection values.
If leadAnchorNotificationEnabled is true, send a notification covering the
old and new lead cells.
leadIndex
- the new lead selection index
removeIndexInterval
public void removeIndexInterval(int index0,
int index1)
Removes a range from the set of indices. Renumbers all indices after
the removed range. This method is typically called to synchronize the
selection model with a deleted range of elements in a
ListModel
.
- removeIndexInterval in interface ListSelectionModel
index0
- The first index to remove (inclusive)index1
- The last index to remove (inclusive)
setLeadSelectionIndex
public void setLeadSelectionIndex(int leadIndex)
Sets the value of the
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
ListSelectionEvent
despite changing multiple ranges. The range of values provided to the
ListSelectionEvent
includes only the minimum range of values
which changed selection status between the beginning and end of the
method.
- setLeadSelectionIndex in interface ListSelectionModel
leadIndex
- The new property value
setSelectionInterval
public void setSelectionInterval(int anchor,
int lead)
Clears the current selection and marks a given interval as "selected". If
the current selection mode is SINGLE_SELECTION
only the
index index2
is selected.
- setSelectionInterval in interface ListSelectionModel
anchor
- the anchor selection index.lead
- the lead selection index.
DefaultListSelectionModel.java --
Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.