模块 java.desktop

接口 TreeNode

所有已知的子接口:
MutableTreeNode
所有已知的实现类:
AbstractDocument.AbstractElement , AbstractDocument.BranchElement , AbstractDocument.LeafElement , DefaultMutableTreeNode , DefaultStyledDocument.SectionElement , HTMLDocument.BlockElement , HTMLDocument.RunElement , JTree.DynamicUtilTreeNode

public interface TreeNode
定义可用作 JTree 中的树节点的对象的要求。

覆盖 equalsTreeNode 实现通常也需要覆盖 hashCode。有关详细信息,请参阅 TreeModel 。有关使用树节点的更多信息和示例,请参阅 The Java Tutorial. 中的 如何使用树节点

  • 方法总结

    修饰符和类型
    方法
    描述
    Enumeration<? extends TreeNode>
    将接收器的子级作为 Enumeration 返回。
    boolean
    如果接收者允许子级,则返回 true。
    getChildAt(int childIndex)
    返回索引 childIndex 处的子节点 TreeNode
    int
    返回接收者包含的孩子 TreeNode 的数量。
    int
    返回接收者孩子中 node 的索引。
    返回接收器的父节点 TreeNode
    boolean
    如果接收者是叶子,则返回 true。
  • 方法详情

    • getChildAt

      TreeNode  getChildAt(int childIndex)
      返回索引 childIndex 处的子节点 TreeNode
      参数:
      childIndex - 孩子的索引
      返回:
      给定索引处的子节点
    • getChildCount

      int getChildCount()
      返回接收者包含的孩子 TreeNode 的数量。
      返回:
      接收者包含的子级数量
    • getParent

      TreeNode  getParent()
      返回接收器的父节点 TreeNode
      返回:
      接收者的父级
    • getIndex

      int getIndex(TreeNode  node)
      返回接收者孩子中 node 的索引。如果接收器不包含 node ,将返回 -1。
      参数:
      node - 要查找的节点
      返回:
      指定节点索引
    • getAllowsChildren

      boolean getAllowsChildren()
      如果接收者允许子级,则返回 true。
      返回:
      接收器是否允许儿童
    • isLeaf

      boolean isLeaf()
      如果接收者是叶子,则返回 true。
      返回:
      接收者是否是叶子
    • children

      Enumeration <? extends TreeNode > children()
      将接收器的子级作为 Enumeration 返回。
      返回:
      接收者的孩子作为 Enumeration