public interface TreeSelectionModel
树的选择国家的特点是由一组treepaths,任选一组整数。从树路径到整数的映射是通过对一个实例进行RowMapper。有一treeselectionmodel RowMapper正确操作是不必要的,但没有RowMapper getSelectionRows
将返回null。
一个treeselectionmodel可以配置为只允许一个通道(SINGLE_TREE_SELECTION
)一系列连续的路径(CONTIGUOUS_TREE_SELECTION
)或多个不连续的路径(DISCONTIGUOUS_TREE_SELECTION
)。一个RowMapper
用于确定treepaths相邻。在没有RowMapper CONTIGUOUS_TREE_SELECTION
和DISCONTIGUOUS_TREE_SELECTION
相同的行为,这是他们允许任何数量的路径被包含在treeselectionmodel。
对于一个CONTIGUOUS_TREE_SELECTION
任何时间的路径选择模型(setSelectionPath
改变,addSelectionPath
…)TreePaths再次做了检查,他们是连续的。支票的treepaths也可以通过调用resetRowSelection
强迫。有一组不连续的TreePaths映射到一组连续的留给这个接口的实现者实施特定的政策。
实现应该合并重复treepaths被添加到选择。例如,下面的代码
树路径[ ] [ ] =新路径树路径树路径树路径{,};treeselectionmodel setselectionpaths(路径);结果应该只有一个选择:
treePath
路径,而不是两份
treePath
。
铅树路径是最后的路径被添加(或设置)。牵头行则对应于树路径从RowMapper确定排。
Modifier and Type | Field and Description |
---|---|
static int |
CONTIGUOUS_TREE_SELECTION
选择只能是连续的。
|
static int |
DISCONTIGUOUS_TREE_SELECTION
选择可以包含任何不一定是连续的项目数。
|
static int |
SINGLE_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改变设置的通知列表。
|
void |
clearSelection()
清空当前的选择。
|
TreePath |
getLeadSelectionPath()
返回添加的最后一条路径。
|
int |
getLeadSelectionRow()
返回引线选择索引。
|
int |
getMaxSelectionRow()
返回最大值为当前选定的treepaths从RowMapper获得。
|
int |
getMinSelectionRow()
返回最小值为当前选定的treepaths从RowMapper获得。
|
RowMapper |
getRowMapper()
返回RowMapper实例,能够绘制一个树路径的一排。
|
int |
getSelectionCount()
返回选择的路径数。
|
int |
getSelectionMode()
返回当前选择的模式,一个
SINGLE_TREE_SELECTION ,
CONTIGUOUS_TREE_SELECTION 或
DISCONTIGUOUS_TREE_SELECTION 。
|
TreePath |
getSelectionPath()
返回选择中的第一个路径。
|
TreePath[] |
getSelectionPaths()
返回选择中的路径。
|
int[] |
getSelectionRows()
返回当前选定行的所有。
|
boolean |
isPathSelected(TreePath path)
如果路径,
path 返回true,在当前的选择。
|
boolean |
isRowSelected(int row)
如果行经
row 选择返回true。
|
boolean |
isSelectionEmpty()
如果选择当前为空,则返回真。
|
void |
removePropertyChangeListener(PropertyChangeListener listener)
从列表中移除侦听器propertychangelistener。
|
void |
removeSelectionPath(TreePath path)
从选择中删除路径。
|
void |
removeSelectionPaths(TreePath[] paths)
从选择中删除路径。
|
void |
removeTreeSelectionListener(TreeSelectionListener x)
删除x从听众,每一次选择的treepaths改变设置的通知列表。
|
void |
resetRowSelection()
更新这个对象的映射从TreePaths行。
|
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[] paths)
设置路径的选择。
|
static final int SINGLE_TREE_SELECTION
static final int CONTIGUOUS_TREE_SELECTION
static final int DISCONTIGUOUS_TREE_SELECTION
void setSelectionMode(int mode)
如果当前的选择对新模式无效,这可能会改变选择。例如,如果三treepaths的时候选择模式更改为SINGLE_TREE_SELECTION
,只有一个树路径仍将选择。它是由特定的实施决定什么TreePath仍然选择。
int getSelectionMode()
SINGLE_TREE_SELECTION
,
CONTIGUOUS_TREE_SELECTION
或
DISCONTIGUOUS_TREE_SELECTION
。
void setSelectionPath(TreePath path)
path
是null,这具有相同的效果
clearSelection
调用。
path
-新的路径选择
void setSelectionPaths(TreePath[] paths)
paths
是null,这具有相同的效果
clearSelection
调用。
paths
新选择
void addSelectionPath(TreePath path)
path
是空的。
path
-添加到当前选择的新路径
void addSelectionPaths(TreePath[] paths)
paths
是空的。
paths
-新的路径添加到当前的选择
void removeSelectionPath(TreePath path)
path
是空的。
path
-从选择删除路径
void removeSelectionPaths(TreePath[] paths)
paths
路径的选择,这treeselectionlisteners通知。如果
paths
为空,该方法没有效果。
paths
-从选择删除路径
TreePath getSelectionPath()
RowMapper
确定。
TreePath[] getSelectionPaths()
int getSelectionCount()
boolean isPathSelected(TreePath path)
path
返回true,在当前的选择。
boolean isSelectionEmpty()
void clearSelection()
void setRowMapper(RowMapper newMapper)
RowMapper getRowMapper()
int[] getSelectionRows()
int getMinSelectionRow()
int getMaxSelectionRow()
boolean isRowSelected(int row)
row
选择返回true。
void resetRowSelection()
你通常不需要调用此;JTree和其相关的听众会调用这个给你。如果你正在实现你自己的视图类,那么你将不得不调用这个。
int getLeadSelectionRow()
TreePath getLeadSelectionPath()
void addPropertyChangeListener(PropertyChangeListener listener)
一个将被解雇时PropertyChangeEvent选择模式的变化。
listener
- propertychangelistener加以补充
void removePropertyChangeListener(PropertyChangeListener listener)
listener
- propertychangelistener被删除
void addTreeSelectionListener(TreeSelectionListener x)
x
-要添加新的听众
void removeTreeSelectionListener(TreeSelectionListener x)
x
听众的去除
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.