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)
用来测试是否一个特定
TreePaths可以添加。
|
protected boolean |
canPathsBeRemoved(TreePath[] paths)
如果路径可以被删除而不破坏模型的连续性,则返回真。
|
void |
clearSelection()
清空当前的选择。
|
Object |
clone()
返回此对象的克隆与相同的选择。
|
protected void |
fireValueChanged(TreeSelectionEvent e)
通知所有的听众,注册该对象树的选择事件。
|
TreePath |
getLeadSelectionPath()
返回添加的最后一条路径。
|
int |
getLeadSelectionRow()
返回引线选择索引。
|
<T extends EventListener> |
getListeners(类<T> listenerType)
返回对象的当前注册为
FooListeners在此模型上的数组。
|
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()
确保当前选定的
TreePaths为当前选择的模式是有效的。
|
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路径被忽略。
如果这是一个变化,所有注册TreeSelectionListeners通知。
引线路径设置为最后一个唯一路径。
从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()
TreeSelectionListeners或空数组如果没有树选择听众正在注册
addTreeSelectionListener(javax.swing.event.TreeSelectionListener),
removeTreeSelectionListener(javax.swing.event.TreeSelectionListener)
protected void fireValueChanged(TreeSelectionEvent e)
public <T extends EventListener> T[] getListeners(类<T> listenerType)
FooListeners在此模型上的数组。
FooListeners使用
addFooListener方法注册。
您可以指定一个类的listenerType字面的说法,如FooListener.class。例如,你可以查询其树种选择的听众与下面的代码DefaultTreeSelectionModel m:
treeselectionlistener [] TSLS =(treeselectionlistener [ ])(m.getlisteners(treeselectionlistener。类));如果没有这样的听众的存在,此方法将返回空数组。
listenerType -听众的类型要求;这个参数应该指定一个接口,从
java.util.EventListener
FooListeners数组,或一个空数组如果没有这样的听众已添加
ClassCastException -如果
listenerType不指定一个类或接口实现
java.util.EventListener
getTreeSelectionListeners(),
getPropertyChangeListeners()
public int[] getSelectionRows()
getSelectionPaths这个方法返回的
TreePaths之间一对一的映射。特别是,如果一个
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注册一个数组。
PropertyChangeListeners或空数组如果没有属性改变监听器正在注册
addPropertyChangeListener(java.beans.PropertyChangeListener),
removePropertyChangeListener(java.beans.PropertyChangeListener)
protected void insureRowContinuity()
TreePaths为当前选择的模式是有效的。如果选择模式的
CONTIGUOUS_TREE_SELECTION和
RowMapper存在,这将确保所有的行是连续的,即,当排序的所有行为无缝隙。如果选择不是连续的,选择被重置为包含第一组,当排序,连续行。
如果选择模式的SINGLE_TREE_SELECTION和多个树路径选择,选择重置包含当前选定的第一路径。
protected boolean arePathsContiguous(TreePath[] paths)
protected boolean canPathsBeAdded(TreePath[] paths)
TreePaths可以添加。这将是如果
paths空返回true(或空),或该对象没有RowMapper,或没有被选中时,或选择模式的
DISCONTIGUOUS_TREE_SELECTION,或添加路径到当前的选择,还是导致了一组连续的
TreePaths。
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.