public class DefaultListSelectionModel extends Object implements ListSelectionModel, Cloneable, Serializable
警告:序列化该类的对象与以后的Swing版本不兼容。当前的序列化支持适用于短期贮藏或RMI运行相同Swing版本的应用程序之间。为1.4,为所有JavaBeans™长期存储的支持已被添加到java.beans
包。请看XMLEncoder
。
ListSelectionModel
Modifier and Type | Field and Description |
---|---|
protected boolean |
leadAnchorNotificationEnabled |
protected EventListenerList |
listenerList |
MULTIPLE_INTERVAL_SELECTION, SINGLE_INTERVAL_SELECTION, SINGLE_SELECTION
Constructor and Description |
---|
DefaultListSelectionModel() |
Modifier and Type | Method and Description |
---|---|
void |
addListSelectionListener(ListSelectionListener l)
向列表中添加一个侦听器,该列表在每次更改时都会通知该列表的更改。
|
void |
addSelectionInterval(int index0, int index1)
变化的选择是当前选择的并集和指数之间的
index0 和
index1 包容。
|
void |
clearSelection()
将选择更改为空集。
|
Object |
clone()
返回此选择模型的一个克隆,选择相同的选择。
|
protected void |
fireValueChanged(boolean isAdjusting)
通知听众,我们已经结束了一系列的调整。
|
protected void |
fireValueChanged(int firstIndex, int lastIndex)
通知
ListSelectionListeners ,选择的价值,在闭区间
firstIndex ,
lastIndex ,改变了。
|
protected void |
fireValueChanged(int firstIndex, int lastIndex, boolean isAdjusting) |
int |
getAnchorSelectionIndex()
返回最近调用第一个指标参数setselectioninterval(),addselectioninterval()或removeselectioninterval()。
|
int |
getLeadSelectionIndex()
返回最近调用二指标参数setselectioninterval(),addselectioninterval()或removeselectioninterval()。
|
<T extends EventListener> |
getListeners(类<T> listenerType)
返回对象的当前注册为
FooListener s在此模型上的数组。
|
ListSelectionListener[] |
getListSelectionListeners()
返回的列表选择的听众对这
DefaultListSelectionModel 注册一个数组。
|
int |
getMaxSelectionIndex()
如果选择是空的,则返回最后一个选择的索引或- 1。
|
int |
getMinSelectionIndex()
如果选择是空的,则返回第一个选择的索引或- 1。
|
int |
getSelectionMode()
返回当前选择模式。
|
boolean |
getValueIsAdjusting()
返回
true 如果选择正在发生一系列的变化。
|
void |
insertIndexInterval(int index, int length, boolean before)
插入长度指数开始前/后指数。
|
boolean |
isLeadAnchorNotificationEnabled()
返回的
leadAnchorNotificationEnabled 标志值。
|
boolean |
isSelectedIndex(int index)
如果选择指定索引,则返回真。
|
boolean |
isSelectionEmpty()
如果没有选择索引,则返回真。
|
void |
moveLeadSelectionIndex(int leadIndex)
设置引导选择索引,使所有选择值保持不变。
|
void |
removeIndexInterval(int index0, int index1)
除去在区间index0指数,指数(含)的选择模型。
|
void |
removeListSelectionListener(ListSelectionListener l)
从所通知的列表中删除一个侦听器,每次更改到选择时发生。
|
void |
removeSelectionInterval(int index0, int index1)
变化的选择是当前选择的差集和指标之间的
index0 和
index1 包容。
|
void |
setAnchorSelectionIndex(int anchorIndex)
设置锚定选择索引,使所有选择值保持不变。
|
void |
setLeadAnchorNotificationEnabled(boolean flag)
套的leadanchornotificationenabled标志值。
|
void |
setLeadSelectionIndex(int leadIndex)
设置引导选择指标,确保锚和新领导之间的值是所有选择或取消选择。
|
void |
setSelectionInterval(int index0, int index1)
变化的选择之间是
index0 和
index1 包容。
|
void |
setSelectionMode(int selectionMode)
设置选择模式。
|
void |
setValueIsAdjusting(boolean isAdjusting)
集
valueIsAdjusting 属性,它指示是否即将到来的选择变化应该被视为一个单一的变化部分。
|
String |
toString()
返回显示并标识该对象属性的字符串。
|
protected EventListenerList listenerList
protected boolean leadAnchorNotificationEnabled
public int getMinSelectionIndex()
getMinSelectionIndex
接口
ListSelectionModel
public int getMaxSelectionIndex()
getMaxSelectionIndex
接口
ListSelectionModel
public boolean getValueIsAdjusting()
true
如果选择正在发生一系列的变化。
getValueIsAdjusting
接口
ListSelectionModel
ListSelectionModel.setValueIsAdjusting(boolean)
public int getSelectionMode()
getSelectionMode
接口
ListSelectionModel
ListSelectionModel.setSelectionMode(int)
public void setSelectionMode(int selectionMode)
ListSelectionModel.SINGLE_SELECTION
-只有一个列表索引一次可以选择。在这种模式下,setSelectionInterval
和addSelectionInterval
是等效的,取代当前的选择由第二个参数表示的指数(“领导”)。ListSelectionModel.SINGLE_INTERVAL_SELECTION
-只有一个连续的时间间隔一次可以选择。在这种模式下,addSelectionInterval
像setSelectionInterval
(替换当前选择),除非给定的时间间隔是相邻或重叠存在的选择,因此可以用来种植它。ListSelectionModel.MULTIPLE_INTERVAL_SELECTION
-在这种模式下,有什么可以选择无限制。setSelectionMode
接口
ListSelectionModel
IllegalArgumentException
如果选择模式并不是那种允许
ListSelectionModel.getSelectionMode()
public boolean isSelectedIndex(int index)
isSelectedIndex
接口
ListSelectionModel
public boolean isSelectionEmpty()
isSelectionEmpty
接口
ListSelectionModel
public void addListSelectionListener(ListSelectionListener l)
addListSelectionListener
接口
ListSelectionModel
l
- ListSelectionListener
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
接口
ListSelectionModel
l
- ListSelectionListener
ListSelectionModel.addListSelectionListener(javax.swing.event.ListSelectionListener)
public ListSelectionListener[] getListSelectionListeners()
DefaultListSelectionModel
注册一个数组。
ListSelectionListener
s或空数组如果没有列表选择听众正在注册
addListSelectionListener(javax.swing.event.ListSelectionListener)
,
removeListSelectionListener(javax.swing.event.ListSelectionListener)
protected void fireValueChanged(boolean isAdjusting)
protected void fireValueChanged(int firstIndex, int lastIndex)
ListSelectionListeners
,选择的价值,在闭区间
firstIndex
,
lastIndex
,改变了。
protected void fireValueChanged(int firstIndex, int lastIndex, boolean isAdjusting)
firstIndex
在区间的第一个索引
lastIndex
在区间上指数
isAdjusting
-如果这是在一系列的调整最终的改变
EventListenerList
public <T extends EventListener> T[] getListeners(类<T> listenerType)
FooListener
s在此模型上的数组。
FooListener
s使用
addFooListener
方法注册。
您可以指定一个类的listenerType
字面的说法,如FooListener.class
。例如,您可以查询的列表选择听众与下面的代码DefaultListSelectionModel
实例m
:
listselectionlistener [] LSLS =(listselectionlistener [ ])(m.getlisteners(listselectionlistener。类));如果没有这样的听众的存在,此方法将返回空数组。
listenerType
-听众的类型要求;这个参数应该指定一个接口,从
java.util.EventListener
FooListener
s数组,或一个空数组如果没有这样的听众已添加
ClassCastException
-如果
listenerType
不指定一个类或接口实现
java.util.EventListener
getListSelectionListeners()
public void setLeadAnchorNotificationEnabled(boolean flag)
public boolean isLeadAnchorNotificationEnabled()
leadAnchorNotificationEnabled
标志值。当
leadAnchorNotificationEnabled
真实模型生成通知事件的范围,覆盖所有更改的选择加上变化的铅和锚定指标。设置标志,假使一个缩小的活动范围只包括元素被选择或取消选择自上的变化。无论哪种方式,该模型继续保持内部的领先和锚定变量。默认是真的。
注:可能的引线或锚被改变,而不改变选择。这些变化的通知往往是重要的,如当新的引线或锚需要在视图中更新。因此,当更改默认值时,请注意警告。
leadAnchorNotificationEnabled
的标志值
setLeadAnchorNotificationEnabled(boolean)
public void clearSelection()
public void setSelectionInterval(int index0, int index1)
index0
和
index1
包容。
index0
不应小于或等于
index1
。
在SINGLE_SELECTION
选择模式,只有二指标应用。
如果这是一个改变当前的选择,然后每个ListSelectionListener
是更改的通知。
如果指数-1
,此方法不返回没有例外。否则,如果指数小于-1
,一IndexOutOfBoundsException
抛出。
setSelectionInterval
接口
ListSelectionModel
index0
-区间的一端。
index1
-区间的另一端
IndexOutOfBoundsException
-如果指数小于
-1
(无论指数是
-1
)
addListSelectionListener(javax.swing.event.ListSelectionListener)
public void addSelectionInterval(int index0, int index1)
index0
和
index1
包容之间的指标。
在SINGLE_SELECTION
选择模式,这相当于调用setSelectionInterval
,只有二指标应用。在SINGLE_INTERVAL_SELECTION
选择模式,这种方法就像setSelectionInterval
,除非给出的区间是相邻或重叠存在的选择,因此可以用来种植它。
如果这是一个改变当前的选择,然后每个ListSelectionListener
是更改的通知。注意,index0
不应小于或等于index1
。
如果指数-1
,此方法不返回没有例外。否则,如果指数小于-1
,一IndexOutOfBoundsException
抛出。
addSelectionInterval
接口
ListSelectionModel
index0
-区间的一端。
index1
-区间的另一端
IndexOutOfBoundsException
-如果指数小于
-1
(无论指数是
-1
)
addListSelectionListener(javax.swing.event.ListSelectionListener)
,
setSelectionInterval(int, int)
public void removeSelectionInterval(int index0, int index1)
index0
和
index1
包容。
index0
不应小于或等于
index1
。
在SINGLE_INTERVAL_SELECTION
选择模式,如果去除会产生两个不相交的选择,去除是通过选择更大的一端延伸。例如,如果选择的是0-10
你供应指标5,6
(按任何顺序)所产生的选择是0-4
。
如果这是一个改变当前的选择,然后每个ListSelectionListener
是更改的通知。
如果指数-1
,此方法不返回没有例外。否则,如果指数小于-1
,一IndexOutOfBoundsException
抛出。
removeSelectionInterval
接口
ListSelectionModel
index0
-区间的一端
index1
-区间的另一端
IndexOutOfBoundsException
-如果指数小于
-1
(无论指数是
-1
)
addListSelectionListener(javax.swing.event.ListSelectionListener)
public void insertIndexInterval(int index, int length, boolean before)
insertIndexInterval
接口
ListSelectionModel
public void removeIndexInterval(int index0, int index1)
removeIndexInterval
接口
ListSelectionModel
public void setValueIsAdjusting(boolean isAdjusting)
valueIsAdjusting
属性,它指示是否即将到来的选择变化应该被视为一个单一的变化部分。此属性的值用于初始化所产生的
ListSelectionEvent
s的
valueIsAdjusting
财产。
例如,如果选择的是响应用户拖动更新,这个属性可以设置为true
当拖启动和设置false
当拖完。在拖动,听众接收事件与valueIsAdjusting
属性设置为true
。在拖到年底,当变化完成,听众接收事件设置为false
价值。听众可以使用这个模式,如果他们想更新只有当改变已经敲定。
将此属性设置为true
开始了一系列的变化,被认为是一个单一的变化部分。当属性被改回false
,事件发出表征整个选择的改变(如果有),与事件的valueIsAdjusting
属性设置为false
。
setValueIsAdjusting
接口
ListSelectionModel
isAdjusting
-新的属性值
ListSelectionModel.getValueIsAdjusting()
,
ListSelectionEvent.getValueIsAdjusting()
public Object clone() throws CloneNotSupportedException
listenerLists
不重复。
clone
方法重写,继承类
Object
CloneNotSupportedException
如果选择模型不同时(一)实现了Cloneable接口和(b)定义了一个
clone
方法。
Cloneable
public int getAnchorSelectionIndex()
public int getLeadSelectionIndex()
public void setAnchorSelectionIndex(int anchorIndex)
setAnchorSelectionIndex
接口
ListSelectionModel
getAnchorSelectionIndex()
,
setLeadSelectionIndex(int)
public void moveLeadSelectionIndex(int leadIndex)
leadIndex
-新的领导选择指数
setAnchorSelectionIndex(int)
,
setLeadSelectionIndex(int)
,
getLeadSelectionIndex()
public void setLeadSelectionIndex(int leadIndex)
如果在锚指标值是不能选择的,做同样的事情在逆向选择的价值观在旧的范围和选择的价值在新的。
为这个更改生成一个单一事件并通知所有的侦听器。为该事件产生的最小范围的目的,通过在一个单一的做手术;这样的第一个和最后一个指标在listselectionevent,广播将细胞实际上改变了价值,因为这种方法。如果,相反,这种操作是在两个步骤中的选择状态的影响将是相同的,但两个事件将产生和改变的值的边界将是更广泛的,包括细胞,已先清除后,将设置。
该方法可用于UI类的mouseDragged
延伸方法的选择。
setLeadSelectionIndex
接口
ListSelectionModel
getLeadSelectionIndex()
,
setAnchorSelectionIndex(int)
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.