public class TreeModelEvent extends EventObject
警告:序列化该类的对象与以后的Swing版本不兼容。当前的序列化支持适用于短期贮藏或RMI运行相同Swing版本的应用程序之间。为1.4,为所有JavaBeans™长期存储的支持已被添加到java.beans
包。请看XMLEncoder
。
Modifier and Type | Field and Description |
---|---|
protected int[] |
childIndices
确定孩子所在位置的指标。
|
protected Object[] |
children
已被移除的孩子。
|
protected TreePath |
path
已更改的节点的父节点的路径。
|
source
Constructor and Description |
---|
TreeModelEvent(Object source, Object[] path)
用于创建一个事件时,节点的结构有一定的变化,确定路径的修改子树的根对象数组。
|
TreeModelEvent(Object source, Object[] path, int[] childIndices, Object[] children)
用于创建节点已被更改、插入或删除的事件,确定将修改后的项目的父对象的路径作为一个对象数组。
|
TreeModelEvent(Object source, TreePath path)
用于创建一个事件时,节点的结构有一定的变化,确定路径的修改子树的根为树路径对象。
|
TreeModelEvent(Object source, TreePath path, int[] childIndices, Object[] children)
用于创建一个事件时,节点被改变,插入或删除,确定路径的修改的项目作为对象的父树路径。
|
Modifier and Type | Method and Description |
---|---|
int[] |
getChildIndices()
返回子索引的值。
|
Object[] |
getChildren()
返回的节点确定在指定的位置
getPath
getChildIndices 儿童对象。
|
Object[] |
getPath()
获取对象数组的实例,这一事件将树路径的便捷方法。
|
TreePath |
getTreePath()
除了treestructurechanged所有事件,返回改变节点的父。
|
String |
toString()
返回显示并标识该对象属性的字符串。
|
getSource
protected TreePath path
protected int[] childIndices
protected Object[] children
public TreeModelEvent(Object source, Object[] path, int[] childIndices, Object[] children)
int
数组,数组必须为指标,从最低到最高。
对于更改,模型中的索引完全对应于当前显示在用户界面中的项目的索引。因此,它不是真的关键,如果索引不在他们的确切顺序。但在多个插入或删除后,当前在用户界面中的项目不再与模型中的项目相对应。因此,关键是要正确指定插入和删除的索引。
对于插入,指标代表树的最终的状态,在插入时有发生。由于索引必须是指定的顺序,最自然的处理方法是做的插入开始在最低的指标,并朝着最高。积累的Integer
对象指定插入位置为你的载体,将载体的int
创建事件数组。当位置指数等于零,节点插入到列表的开始。当位置索引等于列表的大小时,节点将“插入”(附加到)列表的结尾。
对于删除的指标,代表树的最初的状态,在删除时有发生。由于索引必须是指定的顺序,最自然的处理方法是使用一个删除计数器。从柜台零初始化和启动工作从最低到最高的列表。你每次做删除、添加删除计数器,删除发生的索引位置的电流值,并将结果向量删除的位置,使用addElement()
。然后增加删除计数器。存储在向量中的索引位置,因此反映了所有以前的删除的影响,所以它们代表了每个对象在初始树中的位置。(你也可以开始在最高指数和回到工作的最低,积累一个向量删除位置你去使用insertElementAt(Integer, 0)
。)但是你产生初始位置的向量,然后你需要把Integer
对象的矢量来int
创建事件数组。
笔记:
DefaultTreeModel
班insertNodeInto
方法,insertElementAt
追加到Vector
当指数相匹配的矢量的大小。所以你可以用insertElementAt(Integer, 0)
即使向量是空的。null
。source
负责生成事件的对象(通常是事件对象的创造者通过
this
其价值)
path
-物体识别路径的修正项的父数组(S),数组的第一个元素是存储在根节点对象和最后一个元素存储在父节点对象
childIndices
-
int
指定删除的项的索引值的数组。该指数必须在排序顺序,从最低到最高
children
-数组对象包含的插入,删除,或更改的对象
TreePath
public TreeModelEvent(Object source, TreePath path, int[] childIndices, Object[] children)
TreeModelEvent(Object,Object[],int[],Object[])
。
source
负责生成事件的对象(通常是事件对象的创造者通过其价值
this
)
path
-树路径对象标识的修改项的父路径(S)
childIndices
-
int
指定修改的项的索引值的数组
children
-数组对象包含的插入,删除,或更改的对象
TreeModelEvent(Object,Object[],int[],Object[])
public TreeModelEvent(Object source, Object[] path)
Note:
JTree collapses all nodes under the specified node, so that only its immediate children are visible.
source
负责生成事件的对象(通常是事件对象的创造者通过
this
其价值)
path
-物体识别路径的修改子树的根的数组,其中数组的第一个元素存储在根节点对象和最后一个元素存储在改变节点的对象
TreePath
public TreeModelEvent(Object source, TreePath path)
TreeModelEvent(Object,Object[])
。
source
负责生成事件的对象(通常是事件对象的创造者通过
this
其价值)
path
-树路径对象标识的改变路径。在defaulttreemodel,这个对象包含用户数据对象的数组,但树路径的子类可以使用一些完全不同的机制,例如,一个节点的ID号
TreeModelEvent(Object,Object[])
public TreePath getTreePath()
getChildIndices
得到一个受影响的节点列表。
对此的一个例外是treenodeschanged事件,找出根源,在这种情况下,这会返回根和getChildIndices
将返回null。
TreePath.getLastPathComponent()
public Object[] getPath()
public Object[] getChildren()
getPath
getChildIndices
儿童对象。如果这是一个去除事件返回的对象不再是孩子的父节点。
getPath()
,
getChildIndices()
public int[] getChildIndices()
int
数组
public String toString()
toString
方法重写,继承类
EventObject
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.