public class DefaultTreeSelectionModel extends Object implements Cloneable, Serializable, TreeSelectionModel
resetrowselection从任何方法更新选定的路径称为。如果你的类的任何这些方法过滤什么是可以选择的,一定要留言resetRowSelection
如果不消息超。警告:序列化该类的对象与以后的Swing版本不兼容。当前的序列化支持适用于短期贮藏或RMI运行相同Swing版本的应用程序之间。为1.4,为所有JavaBeans™长期存储的支持已被添加到java.beans
包。请看XMLEncoder
。
JTree
Modifier and Type | Field and Description |
---|---|
protected SwingPropertyChangeSupport |
changeSupport
使用短信注册的监听器。
|
protected int |
leadIndex
选择中的引导路径索引。
|
protected TreePath |
leadPath
添加的最后路径。
|
protected int |
leadRow
铅排。
|
protected EventListenerList |
listenerList
事件侦听器列表。
|
protected DefaultListSelectionModel |
listSelectionModel
处理维护列表选择模型。
|
protected RowMapper |
rowMapper
为给定路径提供一个行。
|
protected TreePath[] |
selection
当前选择的路径。
|
static String |
SELECTION_MODE_PROPERTY
selectionMode的属性名称。
|
protected int |
selectionMode
为选择模式,将single_tree_selection,contiguous_tree_selection或discontiguous_tree_selection。
|
CONTIGUOUS_TREE_SELECTION, DISCONTIGUOUS_TREE_SELECTION, SINGLE_TREE_SELECTION
Constructor and Description |
---|
DefaultTreeSelectionModel()
创建defaulttreeselectionmodel是空的一个新实例,有discontiguous_tree_selection选择模式。
|
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener listener)
增加了一个propertychangelistener的监听器列表。
|
void |
addSelectionPath(TreePath path)
添加当前选择的路径。
|
void |
addSelectionPaths(TreePath[] paths)
添加当前选择的路径。
|
void |
addTreeSelectionListener(TreeSelectionListener x)
x的听众,每一次选择的treepaths改变设置的通知列表。
|
protected boolean |
arePathsContiguous(TreePath[] paths)
如果路径是连续的返回true,或者这个对象没有RowMapper。
|
protected boolean |
canPathsBeAdded(TreePath[] paths)
用来测试是否一个特定
TreePath s可以添加。
|
protected boolean |
canPathsBeRemoved(TreePath[] paths)
如果路径可以被删除而不破坏模型的连续性,则返回真。
|
void |
clearSelection()
清空当前的选择。
|
Object |
clone()
返回此对象的克隆与相同的选择。
|
protected void |
fireValueChanged(TreeSelectionEvent e)
通知所有的听众,注册该对象树的选择事件。
|
TreePath |
getLeadSelectionPath()
返回添加的最后一条路径。
|
int |
getLeadSelectionRow()
返回引线选择索引。
|
<T extends EventListener> |
getListeners(类<T> listenerType)
返回对象的当前注册为
FooListener s在此模型上的数组。
|
int |
getMaxSelectionRow()
返回最大值为当前选定的treepaths从RowMapper获得。
|
int |
getMinSelectionRow()
返回最小值为当前选定的treepaths从RowMapper获得。
|
PropertyChangeListener[] |
getPropertyChangeListeners()
返回所有属性改变监听器在这
DefaultTreeSelectionModel 注册一个数组。
|
RowMapper |
getRowMapper()
返回RowMapper实例,能够绘制一个树路径的一排。
|
int |
getSelectionCount()
返回选择的路径数。
|
int |
getSelectionMode()
返回选择模式,一个
SINGLE_TREE_SELECTION ,
DISCONTIGUOUS_TREE_SELECTION 或
CONTIGUOUS_TREE_SELECTION 。
|
TreePath |
getSelectionPath()
返回选择中的第一个路径。
|
TreePath[] |
getSelectionPaths()
返回选择。
|
int[] |
getSelectionRows()
返回行中的选择。
|
TreeSelectionListener[] |
getTreeSelectionListeners()
返回在这个模型上注册的所有树选择侦听器的数组。
|
protected void |
insureRowContinuity()
确保当前选定的
TreePath s为当前选择的模式是有效的。
|
protected void |
insureUniqueness()
这种方法是过时的,其执行的是一个空。
|
boolean |
isPathSelected(TreePath path)
如果路径,
path 返回true,在当前的选择。
|
boolean |
isRowSelected(int row)
如果行经
row 选择返回true。
|
boolean |
isSelectionEmpty()
如果选择当前为空,则返回真。
|
protected void |
notifyPathChange(Vector<?> changedPaths, TreePath oldLeadSelection)
过时的。
作为JDK版本1.7
|
void |
removePropertyChangeListener(PropertyChangeListener listener)
从列表中移除侦听器propertychangelistener。
|
void |
removeSelectionPath(TreePath path)
从选择中删除路径。
|
void |
removeSelectionPaths(TreePath[] paths)
从选择中删除路径。
|
void |
removeTreeSelectionListener(TreeSelectionListener x)
删除x从听众,每一次选择的treepaths改变设置的通知列表。
|
void |
resetRowSelection()
更新此对象映射到行树路径。
|
void |
setRowMapper(RowMapper newMapper)
RowMapper实例集。
|
void |
setSelectionMode(int mode)
集的选择模型,它必须是一个single_tree_selection,contiguous_tree_selection或discontiguous_tree_selection。
|
void |
setSelectionPath(TreePath path)
设置路径的选择。
|
void |
setSelectionPaths(TreePath[] pPaths)
设置选择。
|
String |
toString()
返回显示并标识该对象属性的字符串。
|
protected void |
updateLeadIndex()
更新leadindex实例变量。
|
public static final String SELECTION_MODE_PROPERTY
protected SwingPropertyChangeSupport changeSupport
protected TreePath[] selection
protected EventListenerList listenerList
protected transient RowMapper rowMapper
protected DefaultListSelectionModel listSelectionModel
protected int selectionMode
protected TreePath leadPath
protected int leadIndex
protected int leadRow
public DefaultTreeSelectionModel()
public void setRowMapper(RowMapper newMapper)
setRowMapper
接口
TreeSelectionModel
public RowMapper getRowMapper()
getRowMapper
接口
TreeSelectionModel
public void setSelectionMode(int mode)
DISCONTIGUOUS_TREE_SELECTION
假定。
如果当前的选择对新模式无效,这可能会改变选择。例如,如果三treepaths的时候选择模式更改为SINGLE_TREE_SELECTION
,只有一个树路径仍将选择。它是由特定的实施决定什么TreePath仍然选择。
设置模式的东西比其他类型的定义将导致模式成为DISCONTIGUOUS_TREE_SELECTION
。
setSelectionMode
接口
TreeSelectionModel
public int getSelectionMode()
SINGLE_TREE_SELECTION
,
DISCONTIGUOUS_TREE_SELECTION
或
CONTIGUOUS_TREE_SELECTION
。
getSelectionMode
接口
TreeSelectionModel
public void setSelectionPath(TreePath path)
path
是null,这具有相同的效果
clearSelection
调用。
setSelectionPath
接口
TreeSelectionModel
path
-新的路径选择
public void setSelectionPaths(TreePath[] pPaths)
null
,或空的,选择了。如果选择模式的
SINGLE_TREE_SELECTION
,只有
pPaths
第一路径的使用。如果选择模式的
CONTIGUOUS_TREE_SELECTION
和提供的路径是不连续的,那么只有在
pPaths
第一路径的使用。如果选择模式的
DISCONTIGUOUS_TREE_SELECTION
,然后所有的路径都是用。
在pPaths
所有null
路径被忽略。
如果这是一个变化,所有注册TreeSelectionListener
s通知。
引线路径设置为最后一个唯一路径。
从getSelectionPaths
返回的路径是相同的顺序提供的这种方法。
setSelectionPaths
接口
TreeSelectionModel
pPaths
-新的选择
public void addSelectionPath(TreePath path)
path
是空的。
addSelectionPath
接口
TreeSelectionModel
path
-新的路径添加到当前的选择
public void addSelectionPaths(TreePath[] paths)
paths
是空的。
主要的道路将在paths
的最后一个元素。
如果选择模式的CONTIGUOUS_TREE_SELECTION
,并添加新的路径将选择不连续的。然后两个结果:如果在paths
的treepaths是连续的,那么选择成为这些treepaths,否则treepaths不连续的选择成为paths
第一树路径。
addSelectionPaths
接口
TreeSelectionModel
paths
-新的路径添加到当前的选择
public void removeSelectionPath(TreePath path)
path
是空的。
removeSelectionPath
接口
TreeSelectionModel
path
-从选择删除路径
public void removeSelectionPaths(TreePath[] paths)
paths
是空的。
removeSelectionPaths
接口
TreeSelectionModel
paths
-从选择删除路径
public TreePath getSelectionPath()
getSelectionPath
接口
TreeSelectionModel
public TreePath[] getSelectionPaths()
getSelectionPaths
接口
TreeSelectionModel
public int getSelectionCount()
getSelectionCount
接口
TreeSelectionModel
public boolean isPathSelected(TreePath path)
path
返回true,在当前的选择。
isPathSelected
接口
TreeSelectionModel
public boolean isSelectionEmpty()
isSelectionEmpty
接口
TreeSelectionModel
public void clearSelection()
clearSelection
接口
TreeSelectionModel
public void addTreeSelectionListener(TreeSelectionListener x)
addTreeSelectionListener
接口
TreeSelectionModel
x
-要添加新的听众
public void removeTreeSelectionListener(TreeSelectionListener x)
removeTreeSelectionListener
接口
TreeSelectionModel
x
听众的去除
public TreeSelectionListener[] getTreeSelectionListeners()
TreeSelectionListener
s或空数组如果没有树选择听众正在注册
addTreeSelectionListener(javax.swing.event.TreeSelectionListener)
,
removeTreeSelectionListener(javax.swing.event.TreeSelectionListener)
protected void fireValueChanged(TreeSelectionEvent e)
public <T extends EventListener> T[] getListeners(类<T> listenerType)
FooListener
s在此模型上的数组。
FooListener
s使用
addFooListener
方法注册。
您可以指定一个类的listenerType
字面的说法,如FooListener.class
。例如,你可以查询其树种选择的听众与下面的代码DefaultTreeSelectionModel
m
:
treeselectionlistener [] TSLS =(treeselectionlistener [ ])(m.getlisteners(treeselectionlistener。类));如果没有这样的听众的存在,此方法将返回空数组。
listenerType
-听众的类型要求;这个参数应该指定一个接口,从
java.util.EventListener
FooListener
s数组,或一个空数组如果没有这样的听众已添加
ClassCastException
-如果
listenerType
不指定一个类或接口实现
java.util.EventListener
getTreeSelectionListeners()
,
getPropertyChangeListeners()
public int[] getSelectionRows()
getSelectionPaths
这个方法返回的
TreePath
s之间一对一的映射。特别是,如果一个
TreePath
是不可见的(
-1
的
RowMapper
返回对应的
TreePath
行),然后相应的行不包括在返回的数组中。例如,如果选择由两路径,
A
和
B
,在排
10
A
,和
B
当前不可见,则该方法返回一个单输入
10
阵列。
getSelectionRows
接口
TreeSelectionModel
public int getMinSelectionRow()
getMinSelectionRow
接口
TreeSelectionModel
public int getMaxSelectionRow()
getMaxSelectionRow
接口
TreeSelectionModel
public boolean isRowSelected(int row)
row
选择返回true。
isRowSelected
接口
TreeSelectionModel
public void resetRowSelection()
你通常不需要调用此,JTree和其相关的听众会调用这个给你。如果你正在实现你自己的视图类,那么你将不得不调用这个。
这将调用insureRowContinuity
确保当前选定的treepaths仍然有效的基础上选择模式。
resetRowSelection
接口
TreeSelectionModel
public int getLeadSelectionRow()
getLeadSelectionRow
接口
TreeSelectionModel
public TreePath getLeadSelectionPath()
getLeadSelectionPath
接口
TreeSelectionModel
public void addPropertyChangeListener(PropertyChangeListener listener)
一个将被解雇时PropertyChangeEvent选择模式的变化。
addPropertyChangeListener
接口
TreeSelectionModel
listener
- propertychangelistener加以补充
public void removePropertyChangeListener(PropertyChangeListener listener)
removePropertyChangeListener
接口
TreeSelectionModel
listener
- propertychangelistener被删除
public PropertyChangeListener[] getPropertyChangeListeners()
DefaultTreeSelectionModel
注册一个数组。
PropertyChangeListener
s或空数组如果没有属性改变监听器正在注册
addPropertyChangeListener(java.beans.PropertyChangeListener)
,
removePropertyChangeListener(java.beans.PropertyChangeListener)
protected void insureRowContinuity()
TreePath
s为当前选择的模式是有效的。如果选择模式的
CONTIGUOUS_TREE_SELECTION
和
RowMapper
存在,这将确保所有的行是连续的,即,当排序的所有行为无缝隙。如果选择不是连续的,选择被重置为包含第一组,当排序,连续行。
如果选择模式的SINGLE_TREE_SELECTION
和多个树路径选择,选择重置包含当前选定的第一路径。
protected boolean arePathsContiguous(TreePath[] paths)
protected boolean canPathsBeAdded(TreePath[] paths)
TreePath
s可以添加。这将是如果
paths
空返回true(或空),或该对象没有RowMapper,或没有被选中时,或选择模式的
DISCONTIGUOUS_TREE_SELECTION
,或添加路径到当前的选择,还是导致了一组连续的
TreePath
s。
protected boolean canPathsBeRemoved(TreePath[] paths)
@Deprecated protected void notifyPathChange(Vector<?> changedPaths, TreePath oldLeadSelection)
protected void updateLeadIndex()
protected void insureUniqueness()
public Object clone() throws CloneNotSupportedException
clone
方法重写,继承类
Object
CloneNotSupportedException
从未被这个类的实例
Cloneable
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.