|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.swing.DefaultListSelectionModel
Safe:
Field Summary | |
private int |
anchorIndex
|
private int |
firstAdjustedIndex
|
private int |
firstChangedIndex
|
private boolean |
isAdjusting
|
private int |
lastAdjustedIndex
|
private int |
lastChangedIndex
|
protected boolean |
leadAnchorNotificationEnabled
|
private int |
leadIndex
|
protected EventListenerList |
listenerList
|
private static int |
MAX
|
private int |
maxIndex
|
private static int |
MIN
|
private int |
minIndex
|
private int |
selectionMode
|
private BitSet |
value
|
Fields inherited from interface javax.swing.ListSelectionModel |
MULTIPLE_INTERVAL_SELECTION, SINGLE_INTERVAL_SELECTION, SINGLE_SELECTION |
Constructor Summary | |
DefaultListSelectionModel()
Enabled: |
Method Summary | |
void |
addListSelectionListener(ListSelectionListener l)
Enabled: |
void |
addSelectionInterval(int index0,
int index1)
Enabled: |
private void |
changeSelection(int clearMin,
int clearMax,
int setMin,
int setMax)
Change the selection with the effect of first clearing the values in the inclusive range [clearMin, clearMax] then setting the values in the inclusive range [setMin, setMax]. |
private void |
changeSelection(int clearMin,
int clearMax,
int setMin,
int setMax,
boolean clearFirst)
|
private void |
clear(int r)
|
void |
clearSelection()
Enabled: |
Object |
clone()
Suppressed: Returns a clone of this selection model with the same selection. |
private boolean |
contains(int a,
int b,
int i)
|
private void |
fireValueChanged()
|
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()
Enabled: |
int |
getLeadSelectionIndex()
Enabled: |
EventListener[] |
getListeners(Class listenerType)
Suppressed: Returns an array of all the objects currently registered as FooListener s
upon this model. |
ListSelectionListener[] |
getListSelectionListeners()
Suppressed: Returns an array of all the list selection listeners registered on this DefaultListSelectionModel . |
int |
getMaxSelectionIndex()
Enabled: |
int |
getMinSelectionIndex()
Enabled: |
int |
getSelectionMode()
Enabled: Returns the selection mode. |
boolean |
getValueIsAdjusting()
Enabled: |
void |
insertIndexInterval(int index,
int length,
boolean before)
Enabled: Insert length indices beginning before/after index. |
boolean |
isLeadAnchorNotificationEnabled()
Enabled: Returns the value of the leadAnchorNotificationEnabled flag. |
boolean |
isSelectedIndex(int index)
Enabled: |
boolean |
isSelectionEmpty()
Enabled: |
private void |
markAsDirty(int r)
|
void |
removeIndexInterval(int index0,
int index1)
Enabled: Remove the indices in the interval index0,index1 (inclusive) from the selection model. |
void |
removeListSelectionListener(ListSelectionListener l)
Enabled: |
void |
removeSelectionInterval(int index0,
int index1)
Enabled: |
private void |
set(int r)
|
void |
setAnchorSelectionIndex(int anchorIndex)
Enabled: Set the anchor selection index, leaving all selection values unchanged. |
void |
setLeadAnchorNotificationEnabled(boolean flag)
Enabled: Sets the value of the leadAnchorNotificationEnabled flag. |
void |
setLeadSelectionIndex(int leadIndex)
Enabled: 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)
Enabled: |
void |
setSelectionMode(int selectionMode)
Enabled: Sets the selection mode. |
private void |
setState(int index,
boolean state)
|
void |
setValueIsAdjusting(boolean isAdjusting)
Enabled: |
String |
toString()
Suppressed: Returns a string that displays and identifies this object's properties. |
private void |
updateLeadAnchorIndices(int anchorIndex,
int leadIndex)
|
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private static final int MIN
private static final int MAX
private int selectionMode
private int minIndex
private int maxIndex
private int anchorIndex
private int leadIndex
private int firstAdjustedIndex
private int lastAdjustedIndex
private boolean isAdjusting
private int firstChangedIndex
private int lastChangedIndex
private BitSet value
protected EventListenerList listenerList
protected boolean leadAnchorNotificationEnabled
Constructor Detail |
public DefaultListSelectionModel()
Method Detail |
public int getMinSelectionIndex()
getMinSelectionIndex
in interface ListSelectionModel
public int getMaxSelectionIndex()
getMaxSelectionIndex
in interface ListSelectionModel
public boolean getValueIsAdjusting()
getValueIsAdjusting
in interface ListSelectionModel
ListSelectionModel.setValueIsAdjusting(boolean)
public int getSelectionMode()
getSelectionMode
in interface ListSelectionModel
getSelectionMode()
public void setSelectionMode(int selectionMode)
setSelectionMode
in interface ListSelectionModel
selectionMode
- one of three values:
setSelectionMode(int)
public boolean isSelectedIndex(int index)
isSelectedIndex
in interface ListSelectionModel
public boolean isSelectionEmpty()
isSelectionEmpty
in interface ListSelectionModel
public void addListSelectionListener(ListSelectionListener l)
addListSelectionListener
in interface ListSelectionModel
ListSelectionModel.removeListSelectionListener(javax.swing.event.ListSelectionListener)
,
ListSelectionModel.setSelectionInterval(int, int)
,
ListSelectionModel.addSelectionInterval(int, int)
,
ListSelectionModel.removeSelectionInterval(int, int)
,
ListSelectionModel.clearSelection()
,
ListSelectionModel.insertIndexInterval(int, int, boolean)
,
ListSelectionModel.removeIndexInterval(int, int)
public void removeListSelectionListener(ListSelectionListener l)
removeListSelectionListener
in interface ListSelectionModel
ListSelectionModel.addListSelectionListener(javax.swing.event.ListSelectionListener)
public ListSelectionListener[] getListSelectionListeners()
DefaultListSelectionModel
.
ListSelectionListener
s
or an empty
array if no list selection listeners are currently registeredaddListSelectionListener(javax.swing.event.ListSelectionListener)
,
removeListSelectionListener(javax.swing.event.ListSelectionListener)
protected void fireValueChanged(boolean isAdjusting)
protected void fireValueChanged(int firstIndex, int lastIndex)
ListSelectionListeners
that the value
of the selection, in the closed interval firstIndex
,
lastIndex
, has changed.
protected void fireValueChanged(int firstIndex, int lastIndex, boolean isAdjusting)
firstIndex
- the first index in the intervallastIndex
- the last index in the intervalisAdjusting
- true if this is the final change in a series of
adjustmentsEventListenerList
private void fireValueChanged()
public EventListener[] getListeners(Class listenerType)
FooListener
s
upon this model.
FooListener
s
are registered using the addFooListener
method.
You can specify the listenerType
argument
with a class literal, such as FooListener.class
.
For example, you can query a DefaultListSelectionModel
instance m
for its list selection listeners
with the following code:
ListSelectionListener[] lsls = (ListSelectionListener[])(m.getListeners(ListSelectionListener.class));If no such listeners exist, this method returns an empty array.
listenerType
- the type of listeners requested;
this parameter should specify an interface
that descends from java.util.EventListener
FooListener
s
on this model,
or an empty array if no such
listeners have been addedgetListSelectionListeners()
private void markAsDirty(int r)
private void set(int r)
private void clear(int r)
public void setLeadAnchorNotificationEnabled(boolean flag)
isLeadAnchorNotificationEnabled()
public boolean isLeadAnchorNotificationEnabled()
leadAnchorNotificationEnabled
flag.
When leadAnchorNotificationEnabled
is true the model
generates notification events with bounds that cover all the changes to
the selection plus the changes to the lead and anchor indices.
Setting the flag to false causes a narrowing of the event's bounds to
include only the elements that have been selected or deselected since
the last change. Either way, the model continues to maintain the lead
and anchor variables internally. The default is true.
leadAnchorNotificationEnabled
flagsetLeadAnchorNotificationEnabled(boolean)
private void updateLeadAnchorIndices(int anchorIndex, int leadIndex)
private boolean contains(int a, int b, int i)
private void changeSelection(int clearMin, int clearMax, int setMin, int setMax, boolean clearFirst)
private void changeSelection(int clearMin, int clearMax, int setMin, int setMax)
public void clearSelection()
clearSelection
in interface ListSelectionModel
ListSelectionModel.addListSelectionListener(javax.swing.event.ListSelectionListener)
public void setSelectionInterval(int index0, int index1)
setSelectionInterval
in interface ListSelectionModel
index0
- one end of the interval.index1
- other end of the intervalListSelectionModel.addListSelectionListener(javax.swing.event.ListSelectionListener)
public void addSelectionInterval(int index0, int index1)
addSelectionInterval
in interface ListSelectionModel
index0
- one end of the interval.index1
- other end of the intervalListSelectionModel.addListSelectionListener(javax.swing.event.ListSelectionListener)
public void removeSelectionInterval(int index0, int index1)
removeSelectionInterval
in interface ListSelectionModel
index0
- one end of the interval.index1
- other end of the intervalListSelectionModel.addListSelectionListener(javax.swing.event.ListSelectionListener)
private void setState(int index, boolean state)
public void insertIndexInterval(int index, int length, boolean before)
insertIndexInterval
in interface ListSelectionModel
public void removeIndexInterval(int index0, int index1)
removeIndexInterval
in interface ListSelectionModel
public void setValueIsAdjusting(boolean isAdjusting)
setValueIsAdjusting
in interface ListSelectionModel
isAdjusting
- The new value of the property.ListSelectionModel.getValueIsAdjusting()
public String toString()
toString
in class Object
String
representation of this objectpublic Object clone() throws CloneNotSupportedException
listenerLists
are not duplicated.
clone
in class Object
CloneNotSupportedException
java.lang.Cloneable
public int getAnchorSelectionIndex()
getAnchorSelectionIndex
in interface ListSelectionModel
ListSelectionModel.getLeadSelectionIndex()
,
ListSelectionModel.setSelectionInterval(int, int)
,
ListSelectionModel.addSelectionInterval(int, int)
public int getLeadSelectionIndex()
getLeadSelectionIndex
in interface ListSelectionModel
ListSelectionModel.getAnchorSelectionIndex()
,
ListSelectionModel.setSelectionInterval(int, int)
,
ListSelectionModel.addSelectionInterval(int, int)
public void setAnchorSelectionIndex(int anchorIndex)
setAnchorSelectionIndex
in interface ListSelectionModel
getAnchorSelectionIndex()
,
setLeadSelectionIndex(int)
public void setLeadSelectionIndex(int leadIndex)
If the value at the anchor index is not selected, do the same thing in reverse selecting values in the old range and deslecting values in the new one.
Generate a single event for this change and notify all listeners. For the purposes of generating minimal bounds in this event, do the operation in a single pass; that way the first and last index inside the ListSelectionEvent that is broadcast will refer to cells that actually changed value because of this method. If, instead, this operation were done in two steps the effect on the selection state would be the same but two events would be generated and the bounds around the changed values would be wider, including cells that had been first cleared only to later be set.
This method can be used in the mouseDragged
method
of a UI class to extend a selection.
setLeadSelectionIndex
in interface ListSelectionModel
getLeadSelectionIndex()
,
setAnchorSelectionIndex(int)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |