所有类


javax.swing.tree
类 DefaultTreeSelectionModel

java.lang.Object
  继承者 javax.swing.tree.DefaultTreeSelectionModel
所有已实现的接口:
Serializable, Cloneable, TreeSelectionModel
直接已知子类:
JTree.EmptySelectionModel

public class DefaultTreeSelectionModel
   
   
   
   
extends Object
implements Cloneable, Serializable, TreeSelectionModel

TreeSelectionModel 的默认实现。每当 selection 中的路径(不是行)发生更改时,侦听器就会获得通知。为了能够跟踪行的更改,您可能希望获得一个侦听器,用于树上的扩展事件,并从该位置测试更改。

从所有更新选择路径的方法中调用 resetRowSelection。如果对这些方法中的任何方法创建子类来过滤允许选择的内容,并且没有通知超类,请确定并通知 resetRowSelection

警告:此类的序列化对象将与以后的 Swing 版本不兼容。当前的序列化支持适用于短期存储或运行相同 Swing 版本的应用程序之间的 RMI。从 1.4 版本开始,已在 java.beans 包中添加了支持所有 JavaBeansTM 长期存储的功能。请参见 XMLEncoder

另请参见:
JTree

字段摘要
protected  SwingPropertyChangeSupportchangeSupport
          用于接收通知的注册侦听器。
protected  intleadIndex
          selection 中前导路径的索引。
protected  TreePathleadPath
          添加的最后一条路径。
protected  intleadRow
          前导行。
protected  EventListenerListlistenerList
          事件侦听器列表。
protected  DefaultListSelectionModellistSelectionModel
          维护列表选择模型的句柄。
protected  RowMapperrowMapper
          提供给定路径的行。
protected  TreePath[]selection
          当前选择的路径。
static StringSELECTION_MODE_PROPERTY
          selectionMode 的属性名称。
protected  intselectionMode
          用于 selection 的模式,将是 SINGLE_TREE_SELECTION、CONTIGUOUS_TREE_SELECTION 或 DISCONTIGUOUS_TREE_SELECTION。
 
从接口 javax.swing.tree.TreeSelectionModel 继承的字段
CONTIGUOUS_TREE_SELECTION, DISCONTIGUOUS_TREE_SELECTION, SINGLE_TREE_SELECTION
 
构造方法摘要
DefaultTreeSelectionModel()
          使用 DISCONTIGUOUS_TREE_SELECTION 的选择模式创建空的 DefaultTreeSelectionModel 新实例。
 
方法摘要
 voidaddPropertyChangeListener(PropertyChangeListener listener)
          将 PropertyChangeListener 添加到侦听器列表。
 voidaddSelectionPath(TreePath path)
          将路径添加到当前的 selection 中。
 voidaddSelectionPaths(TreePath[] paths)
          向当前的 selection 中添加路径。
 voidaddTreeSelectionListener(TreeSelectionListener x)
          向每次已选的 TreePaths 集合发生更改时都会得到通知的侦听器列表添加 x。
protected  booleanarePathsContiguous(TreePath[] paths)
          如果路径是连续的,或者此对象没有 RowMapper,则返回 true。
protected  booleancanPathsBeAdded(TreePath[] paths)
          用于测试是否可以添加特定的 TreePath 集合。
protected  booleancanPathsBeRemoved(TreePath[] paths)
          如果可以移除该路径而不中断该模型的连续性,则返回 true。
 voidclearSelection()
          清空当前的 selection。
 Objectclone()
          返回具有相同 selection 的此对象的副本。
protected  voidfireValueChanged(TreeSelectionEvent e)
          通知已注册此对象上的树选择事件的所有侦听器。
 TreePathgetLeadSelectionPath()
          返回添加的最后一条路径。
 intgetLeadSelectionRow()
          返回 lead selection 索引。
<T extends EventListener>
T[]
getListeners(Class<T> listenerType)
          返回当前已在此模型上注册为 FooListener 的所有对象组成的数组。
 intgetMaxSelectionRow()
          返回从 RowMapper 获取的已选择的 TreePath 的当前集合中的最大值。
 intgetMinSelectionRow()
          返回从 RowMapper 获取的已选择的 TreePath 的当前集合中的最小值。
 PropertyChangeListener[]getPropertyChangeListeners()
          返回此 DefaultTreeSelectionModel 上注册的所有属性更改侦听器组成的数组。
 RowMappergetRowMapper()
          返回能够将 TreePath 映射到行的 RowMapper 实例。
 intgetSelectionCount()
          返回选择的路径数。
 intgetSelectionMode()
          返回选择模式,它是 SINGLE_TREE_SELECTIONDISCONTIGUOUS_TREE_SELECTIONCONTIGUOUS_TREE_SELECTION 之一。
 TreePathgetSelectionPath()
          返回 selection 中的第一个路径。
 TreePath[]getSelectionPaths()
          返回 selection 中的路径。
 int[]getSelectionRows()
          返回当前已选的所有行。
 TreeSelectionListener[]getTreeSelectionListeners()
          返回已在此模型上注册的所有树选择侦听器组成的数组。
protected  voidinsureRowContinuity()
          确保当前选择的 TreePath 对于当前选择模式是有效的。
protected  voidinsureUniqueness()
          此方法已过时,并且其实现现在是一个 noop。
 booleanisPathSelected(TreePath path)
          如果当前选择了路径 path,则返回 true。
 booleanisRowSelected(int row)
          如果选择了由 row 标识的行,则返回 true。
 booleanisSelectionEmpty()
          如果 selection 当前为空,则返回 true。
protected  voidnotifyPathChange(Vector<javax.swing.tree.PathPlaceHolder> changedPaths, TreePath oldLeadSelection)
          通知侦听器路径中的更改。
 voidremovePropertyChangeListener(PropertyChangeListener listener)
          从侦听器列表移除 PropertyChangeListener。
 voidremoveSelectionPath(TreePath path)
          从 selection 中移除路径。
 voidremoveSelectionPaths(TreePath[] paths)
          从 selection 中移除路径。
 voidremoveTreeSelectionListener(TreeSelectionListener x)
          从每次已选的 TreePaths 集合发生更改时都会得到通知的侦听器列表中移除 x。
 voidresetRowSelection()
          更新此对象从 TreePath 到行的映射关系。
 voidsetRowMapper(RowMapper newMapper)
          设置 RowMapper 实例。
 voidsetSelectionMode(int mode)
          设置选择模式,它必须是 SINGLE_TREE_SELECTION、CONTIGUOUS_TREE_SELECTION 或 DISCONTIGUOUS_TREE_SELECTION 之一。
 voidsetSelectionPath(TreePath path)
          为该选择设置路径。
 voidsetSelectionPaths(TreePath[] pPaths)
          为该选择设置路径中的路径。
 StringtoString()
          返回显示并标识此对象属性的字符串。
protected  voidupdateLeadIndex()
          更新 leadIndex 实例变量。
 
从类 java.lang.Object 继承的方法
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

字段详细信息

SELECTION_MODE_PROPERTY

public static final String SELECTION_MODE_PROPERTY
selectionMode 的属性名称。

另请参见:
常量字段值

changeSupport

protected SwingPropertyChangeSupport changeSupport
用于接收通知的注册侦听器。


selection

protected TreePath[] selection
当前选择的路径。如果当前没有选择任何内容,则路径为 null。


listenerList

protected EventListenerList listenerList
事件侦听器列表。


rowMapper

protected transient RowMapper rowMapper
提供给定路径的行。


listSelectionModel

protected DefaultListSelectionModel listSelectionModel
维护列表选择模型的句柄。RowMapper 用于从 TreePath 映射到行,并将该值放置在此处。


selectionMode

protected int selectionMode
用于 selection 的模式,将是 SINGLE_TREE_SELECTION、CONTIGUOUS_TREE_SELECTION 或 DISCONTIGUOUS_TREE_SELECTION。