所有类


javax.swing
接口 ListSelectionModel

所有已知实现类:
DefaultListSelectionModel

public interface ListSelectionModel

此接口表示任何组件的当前选择状态,该组件显示一个具有稳定索引的值列表。该选择被建模为一组区间,每个区间表示一个选定列表元素的连续范围。修改该组选定区间的方法都采用一对索引:index0 和 index1,这对索引表示一个闭区间,即该区间同时包括 index0 和 index1。

另请参见:
DefaultListSelectionModel

字段摘要
static intMULTIPLE_INTERVAL_SELECTION
          selectionMode 属性的值:一次选择一个或多个连续的索引范围。
static intSINGLE_INTERVAL_SELECTION
          selectionMode 属性的值:一次选择一个连续的索引范围。
static intSINGLE_SELECTION
          selectionMode 属性的值:一次选择一个列表索引。
 
方法摘要
 voidaddListSelectionListener(ListSelectionListener x)
          将侦听器添加到每次在选择发生更改时都得到通知的列表。
 voidaddSelectionInterval(int index0, int index1)
          将该选择更改为当前选择与 index0 和 index1(包括)之间索引的并集。
 voidclearSelection()
          将该选择更改为空集。
 intgetAnchorSelectionIndex()
          从对 setSelectionInterval()、addSelectionInterval() 或 removeSelectionInterval() 的最近调用中返回第一个索引参数。
 intgetLeadSelectionIndex()
          从对 setSelectionInterval()、addSelectionInterval() 或 removeSelectionInterval() 的最近调用中返回第二个索引参数。
 intgetMaxSelectionIndex()
          返回最后选择的索引,如果选择为空,则返回 -1。
 intgetMinSelectionIndex()
          返回第一个选择的索引,如果选择为空,则返回 -1。
 intgetSelectionMode()
          返回当前选择模式。
 booleangetValueIsAdjusting()
          如果该值在进行一系列更改,则返回 true。
 voidinsertIndexInterval(int index, int length, boolean before)
          在 index 之前/之后开始插入 length 个索引。
 booleanisSelectedIndex(int index)
          如果选择了指定的索引,则返回 true。
 booleanisSelectionEmpty()
          如果没有选择索引,则返回 true。
 voidremoveIndexInterval(int index0, int index1)
          从选择模型中移除区间 index0、index1(包括)中的索引。
 voidremoveListSelectionListener(ListSelectionListener x)
          将侦听器从每次在选择发生更改时都得到通知的列表中移除。
 voidremoveSelectionInterval(int index0, int index1)
          将该选择更改为当前选择与 index0 和 index1(包括)之间索引的差集。
 voidsetAnchorSelectionIndex(int index)
          设置 anchor 选择索引。
 voidsetLeadSelectionIndex(int index)
          设置 lead 选择索引。
 voidsetSelectionInterval(int index0, int index1)
          更改要位于 index0 和 index1(包括)之间的选择。
 voidsetSelectionMode(int selectionMode)
          设置选择模式。
 voidsetValueIsAdjusting(boolean valueIsAdjusting)
          如果将来对该模型的值的更改被视为单个事件,则此属性为 true。
 

字段详细信息

SINGLE_SELECTION

static final int SINGLE_SELECTION
selectionMode 属性的值:一次选择一个列表索引。

另请参见:
setSelectionMode(int), 常量字段值

SINGLE_INTERVAL_SELECTION

static final int SINGLE_INTERVAL_SELECTION
selectionMode 属性的值:一次选择一个连续的索引范围。

另请参见:
setSelectionMode(int), 常量字段值

MULTIPLE_INTERVAL_SELECTION

static final int MULTIPLE_INTERVAL_SELECTION
selectionMode 属性的值:一次选择一个或多个连续的索引范围。

另请参见:
setSelectionMode(int), 常量字段值
方法详细信息

setSelectionInterval

void setSelectionInterval(int index0,
                          int index1)
更改要位于 index0 和 index1(包括)之间的选择。如果这表示对当前选择的更改,则通知每个 ListSelectionListener。注意,index0 不必小于或等于 index1。

参数:
index0 - 区间的一端。
index1 - 区间的另一端
另请参见:
addListSelectionListener(javax.swing.event.ListSelectionListener)

addSelectionInterval

void addSelectionInterval(int index0,
                          int index1)
将该选择更改为当前选择与 index0 和 index1(包括)之间索引的并集。如果这表示对当前选择的更改,则通知每个 ListSelectionListener。注意,index0 不必小于或等于 index1。

参数:
index0 - 区间的一端。
index1 - 区间的另一端
另请参见:
addListSelectionListener(javax.swing.event.ListSelectionListener)

removeSelectionInterval

void removeSelectionInterval(int index0,
                             int index1)
将该选择更改为当前选择与 index0 和 index1(包括)之间索引的差集。如果这表示对当前选择的更改,则通知每个 ListSelectionListener。注意,index0 不必小于或等于 index1。

参数:
index0 - 区间的一端。
index1 - 区间的另一端
另请参见:
addListSelectionListener(javax.swing.event.ListSelectionListener)

getMinSelectionIndex

int getMinSelectionIndex()
返回第一个选择的索引,如果选择为空,则返回 -1。


getMaxSelectionIndex

int getMaxSelectionIndex()
返回最后选择的索引,如果选择为空,则返回 -1。