Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
public interface ListSelectionModel
SINGLE_SELECTION
- only one item in the list may be
selected;SINGLE_INTERVAL_SELECTION
- only one interval in the list
may be selected;MULTIPLE_INTERVAL_SELECTION
- any combination of items in
the list may be selected.ListSelectionListener
) about updates to the selection model.
This model is used to track row selections in the JList
component,
and row and column selections in the JTable
component.
Field Summary | |
static int |
|
static int |
|
static int |
|
Method Summary | |
void |
|
void |
|
void |
|
int |
|
int |
|
int |
|
int |
|
int |
|
boolean |
|
void |
|
boolean |
|
boolean |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
public static final int MULTIPLE_INTERVAL_SELECTION
A selection mode in which any combination of items can be selected.
- Field Value:
- 2
- See Also:
setSelectionMode(int)
public static final int SINGLE_INTERVAL_SELECTION
A selection mode in which a single interval can be selected (an interval is a range containing one or more contiguous items).
- Field Value:
- 1
- See Also:
setSelectionMode(int)
public static final int SINGLE_SELECTION
A selection mode in which only one item can be selected.
- Field Value:
- 0
- See Also:
setSelectionMode(int)
public void addListSelectionListener(ListSelectionListener listener)
Registers a listener with the model so that it receives notification of changes to the model.
- Parameters:
listener
- the listener (null
ignored).
public void addSelectionInterval(int anchor, int lead)
Marks the items in the specified interval as selected. The behaviour of this method depends on the selection mode:Note that
SINGLE_SELECTION
- only thelead
item is selected;SINGLE_INTERVAL_SELECTION
- the existing selection interval is replaced by the specified interval;MULTIPLE_INTERVAL_SELECTION
- the specified interval is merged into the currently selected intervals.anchor
can be less than, equal to, or greater thanlead
.
- Parameters:
anchor
- the index of the anchor itemlead
- the index of the lead item.
public void clearSelection()
Clears the current selection from the model. If the selection state changes (that is, the existing selection is non-empty) aListSelectionEvent
should be sent to all registered listeners.FIXME: what happens to the anchor and lead selection indices (the spec is silent about this)? See:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4334792
public int getAnchorSelectionIndex()
Returns the index of the anchor item.
- Returns:
- The index of the anchor item.
- See Also:
setAnchorSelectionIndex(int)
public int getLeadSelectionIndex()
Returns the index of the lead item.
- Returns:
- The index of the lead item.
- See Also:
setLeadSelectionIndex(int)
public int getMaxSelectionIndex()
Returns the highest selected index, or-1
if there is no selection.
- Returns:
- The highest selected index.
- See Also:
getMinSelectionIndex()
public int getMinSelectionIndex()
Returns the lowest selected index, or-1
if there is no selection.
- Returns:
- The lowest selected index.
- See Also:
getMaxSelectionIndex()
public int getSelectionMode()
Returns the selection mode, which is one ofSINGLE_SELECTION
,SINGLE_INTERVAL_SELECTION
andMULTIPLE_INTERVAL_SELECTION
.
- Returns:
- The selection mode.
- See Also:
setSelectionMode(int)
public boolean getValueIsAdjusting()
Returns a flag that is passed to registered listeners when changes are made to the model. See the description forsetValueIsAdjusting(boolean)
for more information.
- Returns:
- The flag.
public void insertIndexInterval(int index, int length, boolean before)
Inserts a new interval containinglength
items at the specifiedindex
(thebefore
flag indicates whether the range is inserted before or after the existing item atindex
). FIXME: What is the selection status of the new items? Bug 4870694. FIXME: What event is generated?
- Parameters:
index
- the index of the item.length
- the number of items in the interval to be inserted.before
- iftrue
, the interval should be inserted beforeindex
, otherwise it is inserted after.
- See Also:
removeIndexInterval(int,int)
public boolean isSelectedIndex(int index)
Returnstrue
if the specified item is selected, andfalse
otherwise. Special note: ifindex
is negative, this method should returnfalse
(no exception should be thrown).
- Parameters:
index
- the item index (zero-based).
- Returns:
true
if the specified item is selected, andfalse
otherwise.
public boolean isSelectionEmpty()
Returnstrue
if there is no selection, andfalse
otherwise.
- Returns:
true
if there is no selection, andfalse
otherwise.
public void removeIndexInterval(int index0, int index1)
Removes the items in the specified range (inclusive) from the selection model. This method should be called when an interval is deleted from the underlying list. FIXME: what happens to the lead and anchor indices if they are part of the range that is removed? FIXME: what event is generated
- Parameters:
index0
- XXXindex1
- XXX
- See Also:
insertIndexInterval(int,int,boolean)
public void removeListSelectionListener(ListSelectionListener listener)
Deregisters a listener so that it no longer receives notification of changes to the model. If the specified listener is not registered with the model, or isnull
, this method does nothing.
- Parameters:
listener
- the listener (null
ignored).
public void removeSelectionInterval(int anchor, int lead)
Marks the items in the specified interval as not selected. The behaviour of this method depends on the selection mode:Note that
SINGLE_SELECTION
- XXX;SINGLE_INTERVAL_SELECTION
- XXX;MULTIPLE_INTERVAL_SELECTION
- XXX.anchor
can be less than, equal to, or greater thanlead
.
- Parameters:
anchor
- the index of the anchor itemlead
- the index of the lead item.
public void setAnchorSelectionIndex(int index)
Sets the index of the anchor item.
- Parameters:
index
- the item index.
- See Also:
getAnchorSelectionIndex()
public void setLeadSelectionIndex(int index)
Sets the index of the lead item.
- Parameters:
index
- the item index.
- See Also:
getLeadSelectionIndex()
public void setSelectionInterval(int anchor, int lead)
Sets the selection interval to the specified range (note thatanchor
can be less than, equal to, or greater thanlead
). If this results in the selection being changed, aListSelectionEvent
is sent to all registered listeners.If the selection mode is
SINGLE_SELECTION
, only thelead
item is selected.
- Parameters:
anchor
- the anchor index.lead
- the lead index.
public void setSelectionMode(int mode)
Sets the selection mode.FIXME: The spec is silent about what happens to existing selections, for example when changing from an interval selection to single selection.
- Parameters:
mode
- one ofSINGLE_SELECTION
,SINGLE_INTERVAL_SELECTION
andMULTIPLE_INTERVAL_SELECTION
.
- Throws:
IllegalArgumentException
- ifmode
is not one of the specified values.
- See Also:
getSelectionMode()
public void setValueIsAdjusting(boolean valueIsAdjusting)
Sets the flag that is passed to listeners for each change notification. If a sequence of changes is made to the selection model, this flag should be set totrue
at the start of the sequence, andfalse
for the last change - this gives listeners the option to ignore interim changes if that is more efficient.
- Parameters:
valueIsAdjusting
- the flag value.
- See Also:
getValueIsAdjusting()