TreeNode (Java SE 15 & JDK 15) (original) (raw)

All Known Subinterfaces:

[MutableTreeNode](MutableTreeNode.html "interface in javax.swing.tree")

All Known Implementing Classes:

[AbstractDocument.AbstractElement](../text/AbstractDocument.AbstractElement.html "class in javax.swing.text"), [AbstractDocument.BranchElement](../text/AbstractDocument.BranchElement.html "class in javax.swing.text"), [AbstractDocument.LeafElement](../text/AbstractDocument.LeafElement.html "class in javax.swing.text"), [DefaultMutableTreeNode](DefaultMutableTreeNode.html "class in javax.swing.tree"), [DefaultStyledDocument.SectionElement](../text/DefaultStyledDocument.SectionElement.html "class in javax.swing.text"), [HTMLDocument.BlockElement](../text/html/HTMLDocument.BlockElement.html "class in javax.swing.text.html"), [HTMLDocument.RunElement](../text/html/HTMLDocument.RunElement.html "class in javax.swing.text.html"), [JTree.DynamicUtilTreeNode](../JTree.DynamicUtilTreeNode.html "class in javax.swing")


public interface TreeNode

Defines the requirements for an object that can be used as a tree node in a JTree.

Implementations of TreeNode that override equals will typically need to override hashCode as well. Refer to TreeModel for more information. For further information and examples of using tree nodes, see How to Use Tree Nodes in The Java Tutorial.

Modifier and Type Method Description
Enumeration<? extends TreeNode> children() Returns the children of the receiver as an Enumeration.
boolean getAllowsChildren() Returns true if the receiver allows children.
TreeNode getChildAt​(int childIndex) Returns the child TreeNode at indexchildIndex.
int getChildCount() Returns the number of children TreeNodes the receiver contains.
int getIndex​(TreeNode node) Returns the index of node in the receivers children.
TreeNode getParent() Returns the parent TreeNode of the receiver.
boolean isLeaf() Returns true if the receiver is a leaf.