|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jgoodies.binding.adapter.SingleListSelectionAdapter
public final class SingleListSelectionAdapter
A ListSelectionModel
implementation that has the list index
bound to a ValueModel
. Therefore this class supports only
the SINGLE_SELECTION
mode where only one list index
can be selected at a time. In this mode the setSelectionInterval
and addSelectionInterval methods are equivalent, and only
the second index argument (the "lead index") is used.
Example:
SelectionInList selectionInList = new SelectionInList(...); JList list = new JList(); list.setModel(selectionInList); list.setSelectionModel(new SingleListSelectionAdapter( selectionInList.getSelectionIndexHolder()));
ValueModel
,
JList
,
JTable
Field Summary |
---|
Fields inherited from interface javax.swing.ListSelectionModel |
---|
MULTIPLE_INTERVAL_SELECTION, SINGLE_INTERVAL_SELECTION, SINGLE_SELECTION |
Constructor Summary | |
---|---|
SingleListSelectionAdapter(ValueModel selectionIndexHolder)
Constructs a SingleListSelectionAdapter with
the given selection index holder. |
Method Summary | |
---|---|
void |
addListSelectionListener(ListSelectionListener listener)
Add a listener to the list that's notified each time a change to the selection occurs. |
void |
addSelectionInterval(int index0,
int index1)
Sets the selection interval using the given indices. |
void |
clearSelection()
Changes the selection to have no index selected. |
int |
getAnchorSelectionIndex()
Returns the selection index. |
int |
getLeadSelectionIndex()
Returns the selection index. |
ListSelectionListener[] |
getListSelectionListeners()
Returns an array of all the list selection listeners registered on this DefaultListSelectionModel . |
int |
getMaxSelectionIndex()
Returns the selection index. |
int |
getMinSelectionIndex()
Returns the selection index. |
int |
getSelectionMode()
Returns the fixed selection mode SINGLE_SELECTION . |
boolean |
getValueIsAdjusting()
Returns true if the value is undergoing a series of changes. |
void |
insertIndexInterval(int index,
int length,
boolean before)
Inserts length indices beginning before/after index. |
boolean |
isSelectedIndex(int index)
Checks and answers if the given index is selected or not. |
boolean |
isSelectionEmpty()
Returns true if no index is selected. |
void |
removeIndexInterval(int index0,
int index1)
Remove the indices in the interval index0,index1 (inclusive) from the selection model. |
void |
removeListSelectionListener(ListSelectionListener listener)
Remove a listener from the list that's notified each time a change to the selection occurs. |
void |
removeSelectionInterval(int index0,
int index1)
Clears the selection if it is equals to index0. |
void |
setAnchorSelectionIndex(int newSelectionIndex)
Sets the selection index. |
void |
setLeadSelectionIndex(int newSelectionIndex)
Sets the selection index. |
void |
setSelectionInterval(int index0,
int index1)
Sets the selection index to index1 . |
void |
setSelectionMode(int selectionMode)
Sets the selection mode. |
void |
setValueIsAdjusting(boolean newValueIsAdjusting)
This property is true if upcoming changes to the value of the model should be considered a single event. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SingleListSelectionAdapter(ValueModel selectionIndexHolder)
SingleListSelectionAdapter
with
the given selection index holder.
selectionIndexHolder
- holds the selection indexMethod Detail |
---|
public void setSelectionInterval(int index0, int index1)
index1
. Since this model
supports only a single selection index, the index0 is ignored.
This is the behavior the DefaultListSelectionModel
uses in single selection mode.If this represents a change to the current selection, then notify each ListSelectionListener. Note that index0 doesn't have to be less than or equal to index1.
setSelectionInterval
in interface ListSelectionModel
index0
- one end of the interval.index1
- other end of the intervaladdListSelectionListener(ListSelectionListener)
public void addSelectionInterval(int index0, int index1)
If this represents a change to the current selection, then notify each ListSelectionListener. Note that index0 doesn't have to be less than or equal to index1.
addSelectionInterval
in interface ListSelectionModel
index0
- one end of the interval.index1
- other end of the intervaladdListSelectionListener(ListSelectionListener)
public void removeSelectionInterval(int index0, int index1)
If this represents a change to the current selection, then notify each ListSelectionListener. Note that index0 doesn't have to be less than or equal to index1.
removeSelectionInterval
in interface ListSelectionModel
index0
- one end of the interval.index1
- other end of the intervaladdListSelectionListener(ListSelectionListener)
public int getMinSelectionIndex()
getMinSelectionIndex
in interface ListSelectionModel
getMinSelectionIndex()
,
setSelectionInterval(int, int)
,
addSelectionInterval(int, int)
public int getMaxSelectionIndex()
getMaxSelectionIndex
in interface ListSelectionModel
getMinSelectionIndex()
,
setSelectionInterval(int, int)
,
addSelectionInterval(int, int)
public boolean isSelectedIndex(int index)
isSelectedIndex
in interface ListSelectionModel
index
- the index to be checked
ListSelectionModel.isSelectedIndex(int)
public int getAnchorSelectionIndex()
getAnchorSelectionIndex
in interface ListSelectionModel
getAnchorSelectionIndex()
,
setSelectionInterval(int, int)
,
addSelectionInterval(int, int)
public void setAnchorSelectionIndex(int newSelectionIndex)
setAnchorSelectionIndex
in interface ListSelectionModel
newSelectionIndex
- the new selection indexgetLeadSelectionIndex()
public int getLeadSelectionIndex()
getLeadSelectionIndex
in interface ListSelectionModel
getAnchorSelectionIndex()
,
setSelectionInterval(int, int)
,
addSelectionInterval(int, int)
public void setLeadSelectionIndex(int newSelectionIndex)
setLeadSelectionIndex
in interface ListSelectionModel
newSelectionIndex
- the new selection indexgetLeadSelectionIndex()
public void clearSelection()
clearSelection
in interface ListSelectionModel
addListSelectionListener(ListSelectionListener)
public boolean isSelectionEmpty()
isSelectionEmpty
in interface ListSelectionModel
public void insertIndexInterval(int index, int length, boolean before)
insertIndexInterval
in interface ListSelectionModel
index
- the index to start the insertionlength
- the length of the inserted intervalbefore
- true to insert before the start indexpublic void removeIndexInterval(int index0, int index1)
Clears the selection if it is in the specified interval.
removeIndexInterval
in interface ListSelectionModel
index0
- the first index to remove from the selectionindex1
- the last index to remove from the selection
IndexOutOfBoundsException
- if either index0
or index1
are less than -1ListSelectionModel.removeSelectionInterval(int, int)
,
setSelectionInterval(int, int)
,
addSelectionInterval(int, int)
,
addListSelectionListener(ListSelectionListener)
public void setValueIsAdjusting(boolean newValueIsAdjusting)
setValueIsAdjusting
in interface ListSelectionModel
newValueIsAdjusting
- The new value of the property.getValueIsAdjusting()
public boolean getValueIsAdjusting()
getValueIsAdjusting
in interface ListSelectionModel
setValueIsAdjusting(boolean)
public void setSelectionMode(int selectionMode)
SINGLE_SELECTION
is allowed
in this implementation. Other modes are not supported and will throw
an IllegalArgumentException
.
With SINGLE_SELECTION
only one list index
can be selected at a time. In this mode the setSelectionInterval
and addSelectionInterval methods are equivalent, and only
the second index argument (the "lead index") is used.
setSelectionMode
in interface ListSelectionModel
selectionMode
- the mode to be setgetSelectionMode()
,
ListSelectionModel.setSelectionMode(int)
public int getSelectionMode()
SINGLE_SELECTION
.
getSelectionMode
in interface ListSelectionModel
SINGLE_SELECTION
setSelectionMode(int)
public void addListSelectionListener(ListSelectionListener listener)
addListSelectionListener
in interface ListSelectionModel
listener
- the ListSelectionListenerremoveListSelectionListener(ListSelectionListener)
,
setSelectionInterval(int, int)
,
addSelectionInterval(int, int)
,
removeSelectionInterval(int, int)
,
clearSelection()
,
insertIndexInterval(int, int, boolean)
,
removeIndexInterval(int, int)
public void removeListSelectionListener(ListSelectionListener listener)
removeListSelectionListener
in interface ListSelectionModel
listener
- the ListSelectionListeneraddListSelectionListener(ListSelectionListener)
public ListSelectionListener[] getListSelectionListeners()
DefaultListSelectionModel
.
ListSelectionListener
s
or an empty
array if no list selection listeners are currently registeredaddListSelectionListener(ListSelectionListener)
,
removeListSelectionListener(ListSelectionListener)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |