public interface TreeNode
定义可以用作 JTree 中树节点的对象所需的要求。
重写 equals 的 TreeNode 的实现通常也需要重写 hashCode。有关更多信息,请参阅 TreeModel。 有关使用树节点的更多信息和示例,请参阅 The Java Tutorial 中的 How to Use Tree Nodes。
| 方法摘要 | |
|---|---|
Enumeration |
children() 以 Enumeration 的形式返回接收者的子节点。 |
boolean |
getAllowsChildren() 如果接收者允许有子节点,则返回 true。 |
TreeNode |
getChildAt(int childIndex) 返回索引 childIndex 位置的子 TreeNode。 |
int |
getChildCount() 返回接收者包含的子 TreeNode 数。 |
int |
getIndex(TreeNode node) 返回接收者子节点中的 node 的索引。 |
TreeNode |
getParent() 返回接收者的父 TreeNode。 |
boolean |
isLeaf() 如果接收者是一个叶节点,则返回 true。 |
| 方法详细信息 |
|---|
TreeNode getChildAt(int childIndex)
childIndex 位置的子
TreeNode。
int getChildCount()
TreeNode 数。
TreeNode getParent()
TreeNode。
int getIndex(TreeNode node)
node 的索引。如果接收者不包含
node,则返回 -1。
boolean getAllowsChildren()
boolean isLeaf()
Enumeration children()
Enumeration 的形式返回接收者的子节点。