Class TreeNode


  • public final class TreeNode
    extends java.lang.Object
    A node in a TreeView: a label, ordered children, and an expanded flag.
    • Constructor Summary

      Constructors 
      Constructor Description
      TreeNode​(java.lang.String label)
      Creates a leaf node with the given label.
    • Constructor Detail

      • TreeNode

        public TreeNode​(java.lang.String label)
        Creates a leaf node with the given label.
        Parameters:
        label - the label text; treated as empty if null
    • Method Detail

      • add

        public TreeNode add​(TreeNode child)
        Appends a child node.
        Parameters:
        child - the child node to add
        Returns:
        this TreeNode for chaining
      • label

        public java.lang.String label()
        Returns:
        the label text
      • children

        public java.util.List<TreeNode> children()
        Returns:
        an unmodifiable list of the children, in order
      • isLeaf

        public boolean isLeaf()
        Returns:
        true if this node has no children
      • isExpanded

        public boolean isExpanded()
        Returns:
        true if expanded
      • expanded

        public TreeNode expanded​(boolean expanded)
        Sets whether this node is expanded.
        Parameters:
        expanded - the new state
        Returns:
        this TreeNode for chaining