java.applet

java.awt

java.awt.color

java.awt.datatransfer

java.awt.dnd

java.awt.event

java.awt.font

java.awt.geom

java.awt.im

java.awt.im.spi

java.awt.image

java.awt.image.renderable

java.awt.print

java.beans

java.beans.beancontext

java.io

java.lang

java.lang.annotation

java.lang.instrument

java.lang.management

java.lang.ref

java.lang.reflect

java.math

java.net

java.nio

java.nio.channels

java.nio.channels.spi

java.nio.charset

java.nio.charset.spi

java.rmi

java.rmi.activation

java.rmi.dgc

java.rmi.registry

java.rmi.server

java.security

java.security.acl

java.security.cert

java.security.interfaces

java.security.spec

java.sql

java.text

java.util

java.util.concurrent

java.util.concurrent.atomic

java.util.concurrent.locks

java.util.jar

java.util.logging

java.util.prefs

java.util.regex

java.util.zip

javax.accessibility

javax.activity

javax.crypto

javax.crypto.interfaces

javax.crypto.spec

javax.imageio

javax.imageio.event

javax.imageio.metadata

javax.imageio.plugins.bmp

javax.imageio.plugins.jpeg

javax.imageio.spi

javax.imageio.stream

javax.management

javax.management.loading

javax.management.modelmbean

javax.management.monitor

javax.management.openmbean

javax.management.relation

javax.management.remote

javax.management.remote.rmi

javax.management.timer

javax.naming

javax.naming.directory

javax.naming.event

javax.naming.ldap

javax.naming.spi

javax.net

javax.net.ssl

javax.print

javax.print.attribute

javax.print.attribute.standard

javax.print.event

javax.rmi

javax.rmi.CORBA

javax.rmi.ssl

javax.security.auth

javax.security.auth.callback

javax.security.auth.kerberos

javax.security.auth.login

javax.security.auth.spi

javax.security.auth.x500

javax.security.cert

javax.security.sasl

javax.sound.midi

javax.sound.midi.spi

javax.sound.sampled

javax.sound.sampled.spi

javax.sql

javax.sql.rowset

javax.sql.rowset.serial

javax.sql.rowset.spi

javax.swing

javax.swing.border

javax.swing.colorchooser

javax.swing.event

javax.swing.filechooser

javax.swing.plaf

javax.swing.plaf.basic

javax.swing.plaf.metal

javax.swing.plaf.multi

javax.swing.plaf.synth

javax.swing.table

javax.swing.text

javax.swing.text

javax.swing.text.parser

javax.swing.text.rtf

javax.swing.tree

javax.swing.undo

javax.transaction

javax.transaction.xa

javax.xml

javax.xml.datatype

javax.xml.namespace

javax.xml.parsers

javax.xml.transform

javax.xml.transform.dom

javax.xml.transform.sax

javax.xml.transform.stream

javax.xml.validation

javax.xml.xpath

org.ietf.jgss

org.omg.CORBA

org.omg.CORBA_2_3

org.omg.CORBA_2_3.portable

org.omg.CORBA.DynAnyPackage

org.omg.CORBA.ORBPackage

org.omg.CORBA.portable

org.omg.CORBA.TypeCodePackage

org.omg.CosNaming

org.omg.CosNaming.NamingContextExtPackage

org.omg.CosNaming.NamingContextPackage

org.omg.Dynamic

org.omg.DynamicAny

org.omg.DynamicAny.DynAnyFactoryPackage

org.omg.DynamicAny.DynAnyPackage

org.omg.IOP

org.omg.IOP.CodecFactoryPackage

org.omg.IOP.CodecPackage

org.omg.Messaging

org.omg.PortableInterceptor

org.omg.PortableInterceptor.ORBInitInfoPackage

org.omg.PortableServer

org.omg.PortableServer.CurrentPackage

org.omg.PortableServer.POAManagerPackage

org.omg.PortableServer.POAPackage

org.omg.PortableServer.portable

org.omg.PortableServer.ServantLocatorPackage

org.omg.SendingContext

org.omg.stub.java.rmi

org.w3c.dom

org.w3c.dom.bootstrap

org.w3c.dom.events

org.w3c.dom.ls

org.xml.sax

org.xml.sax.ext

org.xml.sax.helpers

allclasses-frame

allclasses-noframe

constant-values

deprecated-list

help-doc

JavaTM 2 Platform
Standard Ed. 5.0

javax.swing
接口 ListSelectionModel

所有已知实现类:
DefaultListSelectionModel

public interface ListSelectionModel

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

另请参见:
DefaultListSelectionModel

字段摘要
static int MULTIPLE_INTERVAL_SELECTION
          selectionMode 属性的值:一次选择一个或多个连续的索引范围。
static int SINGLE_INTERVAL_SELECTION
          selectionMode 属性的值:一次选择一个连续的索引范围。
static int SINGLE_SELECTION
          selectionMode 属性的值:一次选择一个列表索引。
 
方法摘要
 void addListSelectionListener(ListSelectionListener x)
          将侦听器添加到每次在选择发生更改时都得到通知的列表。
 void addSelectionInterval(int index0, int index1)
          将该选择更改为当前选择与 index0 和 index1(包括)之间索引的并集。
 void clearSelection()
          将该选择更改为空集。
 int getAnchorSelectionIndex()
          从对 setSelectionInterval()、addSelectionInterval() 或 removeSelectionInterval() 的最近调用中返回第一个索引参数。
 int getLeadSelectionIndex()
          从对 setSelectionInterval()、addSelectionInterval() 或 removeSelectionInterval() 的最近调用中返回第二个索引参数。
 int getMaxSelectionIndex()
          返回最后选择的索引,如果选择为空,则返回 -1。
 int getMinSelectionIndex()
          返回第一个选择的索引,如果选择为空,则返回 -1。
 int getSelectionMode()
          返回当前选择模式。
 boolean getValueIsAdjusting()
          如果该值在进行一系列更改,则返回 true。
 void insertIndexInterval(int index, int length, boolean before)
          在 index 之前/之后开始插入 length 个索引。
 boolean isSelectedIndex(int index)
          如果选择了指定的索引,则返回 true。
 boolean isSelectionEmpty()
          如果没有选择索引,则返回 true。
 void removeIndexInterval(int index0, int index1)
          从选择模型中移除区间 index0、index1(包括)中的索引。
 void removeListSelectionListener(ListSelectionListener x)
          将侦听器从每次在选择发生更改时都得到通知的列表中移除。
 void removeSelectionInterval(int index0, int index1)
          将该选择更改为当前选择与 index0 和 index1(包括)之间索引的差集。
 void setAnchorSelectionIndex(int index)
          设置 anchor 选择索引。
 void setLeadSelectionIndex(int index)
          设置 lead 选择索引。
 void setSelectionInterval(int index0, int index1)
          更改要位于 index0 和 index1(包括)之间的选择。
 void setSelectionMode(int selectionMode)
          设置选择模式。
 void setValueIsAdjusting(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。


isSelectedIndex

boolean isSelectedIndex(int index)
如果选择了指定的索引,则返回 true。


getAnchorSelectionIndex

int getAnchorSelectionIndex()
从对 setSelectionInterval()、addSelectionInterval() 或 removeSelectionInterval() 的最近调用中返回第一个索引参数。最近的 index0 被认为是 "anchor",最近的 index1 被认为是 "lead"。一些界面特别地显示这些索引,例如,Windows95 显示带有黄色点式轮廓的 lead 索引。

另请参见:
getLeadSelectionIndex(), setSelectionInterval(int, int), addSelectionInterval(int, int)

setAnchorSelectionIndex

void setAnchorSelectionIndex(int index)
设置 anchor 选择索引。

另请参见:
getAnchorSelectionIndex()

getLeadSelectionIndex

int getLeadSelectionIndex()
从对 setSelectionInterval()、addSelectionInterval() 或 removeSelectionInterval() 的最近调用中返回第二个索引参数。

另请参见:
getAnchorSelectionIndex(), setSelectionInterval(int, int), addSelectionInterval(int, int)

setLeadSelectionIndex

void setLeadSelectionIndex(int index)
设置 lead 选择索引。

另请参见:
getLeadSelectionIndex()

clearSelection

void clearSelection()
将该选择更改为空集。如果这表示对当前选择的更改,则通知每个 ListSelectionListener。

另请参见:
addListSelectionListener(javax.swing.event.ListSelectionListener)

isSelectionEmpty

boolean isSelectionEmpty()
如果没有选择索引,则返回 true。


insertIndexInterval

void insertIndexInterval(int index,
                         int length,
                         boolean before)
在 index 之前/之后开始插入 length 个索引。通常调用此方法来同步选择模型与数据模型中的相应更改。


removeIndexInterval

void removeIndexInterval(int index0,
                         int index1)
从选择模型中移除区间 index0、index1(包括)中的索引。通常调用此方法来同步选择模型与数据模型中的相应更改。


setValueIsAdjusting

void setValueIsAdjusting(boolean valueIsAdjusting)
如果将来对该模型的值的更改被视为单个事件,则此属性为 true。例如,如果在更新该模型以响应一个用户的拖动,则 valueIsAdjusting 属性的值在发起该拖动操作时将被设置为 true,并在该拖动操作结束时被设置为 false。此属性允许侦听器仅在更改结束时进行更新,而不是始终处理所有的中间值。

参数:
valueIsAdjusting - 属性的新值。
另请参见:
getValueIsAdjusting()

getValueIsAdjusting

boolean getValueIsAdjusting()
如果该值在进行一系列更改,则返回 true。

返回:
如果正在调整该值,则返回 true
另请参见:
setValueIsAdjusting(boolean)

setSelectionMode

void setSelectionMode(int selectionMode)
设置选择模式。允许以下 selectionMode 值:
  • SINGLE_SELECTION 一次只能选择一个列表索引。在此模式中,setSelectionInterval 和 addSelectionInterval 方法是等效的,而且仅使用第二个索引参数(“lead 索引”)。
  • SINGLE_INTERVAL_SELECTION 一次只能选择一个连续索引区间。在此模式中,setSelectionInterval 和 addSelectionInterval 是等效的。
  • MULTIPLE_INTERVAL_SELECTION 在此模式中,对选择内容无任何限制。

另请参见:
getSelectionMode()

getSelectionMode

int getSelectionMode()
返回当前选择模式。

返回:
selectionMode 属性的值。
另请参见:
setSelectionMode(int)

addListSelectionListener

void addListSelectionListener(ListSelectionListener x)
将侦听器添加到每次在选择发生更改时都得到通知的列表。

参数:
x - ListSelectionListener
另请参见:
removeListSelectionListener(javax.swing.event.ListSelectionListener), setSelectionInterval(int, int), addSelectionInterval(int, int), removeSelectionInterval(int, int), clearSelection(), insertIndexInterval(int, int, boolean), removeIndexInterval(int, int)

removeListSelectionListener

void removeListSelectionListener(ListSelectionListener x)
将侦听器从每次在选择发生更改时都得到通知的列表中移除。

参数:
x - ListSelectionListener
另请参见:
addListSelectionListener(javax.swing.event.ListSelectionListener)

JavaTM 2 Platform
Standard Ed. 5.0

提交错误或意见
有关更多的 API 参考资料和开发人员文档,请参阅 Java 2 SDK SE 开发人员文档。该文档包含更详细的、面向开发人员的描述,以及总体概述、术语定义、使用技巧和工作代码示例。

版权所有 2004 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策