TreeNode (Java SE 19 & JDK 19) (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.
Method Summary
[children](#children%28%29)()
Returns the children of the receiver as an Enumeration
.boolean
Returns true if the receiver allows children.[getChildAt](#getChildAt%28int%29)(int childIndex)
Returns the child TreeNode
at indexchildIndex
.int
Returns the number of children TreeNode
s the receiver contains.int
Returns the index of node
in the receivers children.[getParent](#getParent%28%29)()
Returns the parent TreeNode
of the receiver.boolean
[isLeaf](#isLeaf%28%29)()
Returns true if the receiver is a leaf.
Method Details
getChildAt
TreeNode getChildAt(int childIndex)
Returns the childTreeNode
at indexchildIndex
.
Parameters:
childIndex
- index of child
Returns:
the child node at given indexgetChildCount
int getChildCount()
Returns the number of childrenTreeNode
s the receiver contains.
Returns:
the number of children the receiver containsgetParent
Returns the parent
TreeNode
of the receiver.
Returns:
the parent of the receivergetIndex
Returns the index of
node
in the receivers children. If the receiver does not containnode
, -1 will be returned.
Parameters:
node
- node to be loked for
Returns:
index of specified nodegetAllowsChildren
boolean getAllowsChildren()
Returns true if the receiver allows children.
Returns:
whether the receiver allows childrenisLeaf
boolean isLeaf()
Returns true if the receiver is a leaf.
Returns:
whether the receiver is a leafchildren
Returns the children of the receiver as an
Enumeration
.
Returns:
the children of the receiver as anEnumeration