JTree.DynamicUtilTreeNode (Java Platform SE 8 ) (original) (raw)
- javax.swing.tree.DefaultMutableTreeNode
- javax.swing.JTree.DynamicUtilTreeNode
All Implemented Interfaces:
Serializable, Cloneable, MutableTreeNode, TreeNode
Enclosing class:
JTree
public static class JTree.DynamicUtilTreeNode
extends DefaultMutableTreeNodeDynamicUtilTreeNode
can wrap vectors/hashtables/arrays/strings and create the appropriate children tree nodes as necessary. It is dynamic in that it will only create the children as necessary.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans™ has been added to the java.beans
package. Please see XMLEncoder.
Field Summary
Fields
Modifier and Type Field Description protected Object childValue Value to create children with. protected boolean hasChildren Does the this JTree have children? This property is currently not implemented. protected boolean loadedChildren Have the children been loaded yet? * ### Fields inherited from class javax.swing.tree.[DefaultMutableTreeNode](../../javax/swing/tree/DefaultMutableTreeNode.html "class in javax.swing.tree") `[allowsChildren](../../javax/swing/tree/DefaultMutableTreeNode.html#allowsChildren), [children](../../javax/swing/tree/DefaultMutableTreeNode.html#children), [EMPTY_ENUMERATION](../../javax/swing/tree/DefaultMutableTreeNode.html#EMPTY%5FENUMERATION), [parent](../../javax/swing/tree/DefaultMutableTreeNode.html#parent), [userObject](../../javax/swing/tree/DefaultMutableTreeNode.html#userObject)`
Constructor Summary
Constructors
Constructor Description DynamicUtilTreeNode(Object value,Object children) Creates a node with the specified object as its value and with the specified children. Method Summary
All Methods Static Methods Instance Methods Concrete Methods
Modifier and Type Method Description Enumeration children() Subclassed to load the children, if necessary. static void createChildren(DefaultMutableTreeNode parent,Object children) Adds to parent all the children in children. TreeNode getChildAt(int index) Subclassed to load the children, if necessary. int getChildCount() Returns the number of child nodes. boolean isLeaf() Returns true if this node allows children. protected void loadChildren() Loads the children based on childValue. * ### Methods inherited from class javax.swing.tree.[DefaultMutableTreeNode](../../javax/swing/tree/DefaultMutableTreeNode.html "class in javax.swing.tree") `[add](../../javax/swing/tree/DefaultMutableTreeNode.html#add-javax.swing.tree.MutableTreeNode-), [breadthFirstEnumeration](../../javax/swing/tree/DefaultMutableTreeNode.html#breadthFirstEnumeration--), [clone](../../javax/swing/tree/DefaultMutableTreeNode.html#clone--), [depthFirstEnumeration](../../javax/swing/tree/DefaultMutableTreeNode.html#depthFirstEnumeration--), [getAllowsChildren](../../javax/swing/tree/DefaultMutableTreeNode.html#getAllowsChildren--), [getChildAfter](../../javax/swing/tree/DefaultMutableTreeNode.html#getChildAfter-javax.swing.tree.TreeNode-), [getChildBefore](../../javax/swing/tree/DefaultMutableTreeNode.html#getChildBefore-javax.swing.tree.TreeNode-), [getDepth](../../javax/swing/tree/DefaultMutableTreeNode.html#getDepth--), [getFirstChild](../../javax/swing/tree/DefaultMutableTreeNode.html#getFirstChild--), [getFirstLeaf](../../javax/swing/tree/DefaultMutableTreeNode.html#getFirstLeaf--), [getIndex](../../javax/swing/tree/DefaultMutableTreeNode.html#getIndex-javax.swing.tree.TreeNode-), [getLastChild](../../javax/swing/tree/DefaultMutableTreeNode.html#getLastChild--), [getLastLeaf](../../javax/swing/tree/DefaultMutableTreeNode.html#getLastLeaf--), [getLeafCount](../../javax/swing/tree/DefaultMutableTreeNode.html#getLeafCount--), [getLevel](../../javax/swing/tree/DefaultMutableTreeNode.html#getLevel--), [getNextLeaf](../../javax/swing/tree/DefaultMutableTreeNode.html#getNextLeaf--), [getNextNode](../../javax/swing/tree/DefaultMutableTreeNode.html#getNextNode--), [getNextSibling](../../javax/swing/tree/DefaultMutableTreeNode.html#getNextSibling--), [getParent](../../javax/swing/tree/DefaultMutableTreeNode.html#getParent--), [getPath](../../javax/swing/tree/DefaultMutableTreeNode.html#getPath--), [getPathToRoot](../../javax/swing/tree/DefaultMutableTreeNode.html#getPathToRoot-javax.swing.tree.TreeNode-int-), [getPreviousLeaf](../../javax/swing/tree/DefaultMutableTreeNode.html#getPreviousLeaf--), [getPreviousNode](../../javax/swing/tree/DefaultMutableTreeNode.html#getPreviousNode--), [getPreviousSibling](../../javax/swing/tree/DefaultMutableTreeNode.html#getPreviousSibling--), [getRoot](../../javax/swing/tree/DefaultMutableTreeNode.html#getRoot--), [getSharedAncestor](../../javax/swing/tree/DefaultMutableTreeNode.html#getSharedAncestor-javax.swing.tree.DefaultMutableTreeNode-), [getSiblingCount](../../javax/swing/tree/DefaultMutableTreeNode.html#getSiblingCount--), [getUserObject](../../javax/swing/tree/DefaultMutableTreeNode.html#getUserObject--), [getUserObjectPath](../../javax/swing/tree/DefaultMutableTreeNode.html#getUserObjectPath--), [insert](../../javax/swing/tree/DefaultMutableTreeNode.html#insert-javax.swing.tree.MutableTreeNode-int-), [isNodeAncestor](../../javax/swing/tree/DefaultMutableTreeNode.html#isNodeAncestor-javax.swing.tree.TreeNode-), [isNodeChild](../../javax/swing/tree/DefaultMutableTreeNode.html#isNodeChild-javax.swing.tree.TreeNode-), [isNodeDescendant](../../javax/swing/tree/DefaultMutableTreeNode.html#isNodeDescendant-javax.swing.tree.DefaultMutableTreeNode-), [isNodeRelated](../../javax/swing/tree/DefaultMutableTreeNode.html#isNodeRelated-javax.swing.tree.DefaultMutableTreeNode-), [isNodeSibling](../../javax/swing/tree/DefaultMutableTreeNode.html#isNodeSibling-javax.swing.tree.TreeNode-), [isRoot](../../javax/swing/tree/DefaultMutableTreeNode.html#isRoot--), [pathFromAncestorEnumeration](../../javax/swing/tree/DefaultMutableTreeNode.html#pathFromAncestorEnumeration-javax.swing.tree.TreeNode-), [postorderEnumeration](../../javax/swing/tree/DefaultMutableTreeNode.html#postorderEnumeration--), [preorderEnumeration](../../javax/swing/tree/DefaultMutableTreeNode.html#preorderEnumeration--), [remove](../../javax/swing/tree/DefaultMutableTreeNode.html#remove-int-), [remove](../../javax/swing/tree/DefaultMutableTreeNode.html#remove-javax.swing.tree.MutableTreeNode-), [removeAllChildren](../../javax/swing/tree/DefaultMutableTreeNode.html#removeAllChildren--), [removeFromParent](../../javax/swing/tree/DefaultMutableTreeNode.html#removeFromParent--), [setAllowsChildren](../../javax/swing/tree/DefaultMutableTreeNode.html#setAllowsChildren-boolean-), [setParent](../../javax/swing/tree/DefaultMutableTreeNode.html#setParent-javax.swing.tree.MutableTreeNode-), [setUserObject](../../javax/swing/tree/DefaultMutableTreeNode.html#setUserObject-java.lang.Object-), [toString](../../javax/swing/tree/DefaultMutableTreeNode.html#toString--)` * ### Methods inherited from class java.lang.[Object](../../java/lang/Object.html "class in java.lang") `[equals](../../java/lang/Object.html#equals-java.lang.Object-), [finalize](../../java/lang/Object.html#finalize--), [getClass](../../java/lang/Object.html#getClass--), [hashCode](../../java/lang/Object.html#hashCode--), [notify](../../java/lang/Object.html#notify--), [notifyAll](../../java/lang/Object.html#notifyAll--), [wait](../../java/lang/Object.html#wait--), [wait](../../java/lang/Object.html#wait-long-), [wait](../../java/lang/Object.html#wait-long-int-)`
Field Detail
* #### hasChildren protected boolean hasChildren Does the this `JTree` have children? This property is currently not implemented. * #### childValue protected [Object](../../java/lang/Object.html "class in java.lang") childValue Value to create children with. * #### loadedChildren protected boolean loadedChildren Have the children been loaded yet?
Constructor Detail
* #### DynamicUtilTreeNode public DynamicUtilTreeNode([Object](../../java/lang/Object.html "class in java.lang") value, [Object](../../java/lang/Object.html "class in java.lang") children) Creates a node with the specified object as its value and with the specified children. For the node to allow children, the children-object must be an array of objects, a`Vector`, or a `Hashtable` \-- even if empty. Otherwise, the node is not allowed to have children. Parameters: `value` \- the `Object` that is the value for the new node `children` \- an array of `Object`s, a`Vector`, or a `Hashtable` used to create the child nodes; if any other object is specified, or if the value is`null`, then the node is not allowed to have children
Method Detail
* #### createChildren public static void createChildren([DefaultMutableTreeNode](../../javax/swing/tree/DefaultMutableTreeNode.html "class in javax.swing.tree") parent, [Object](../../java/lang/Object.html "class in java.lang") children) Adds to parent all the children in `children`. If `children` is an array or vector all of its elements are added is children, otherwise if `children` is a hashtable all the key/value pairs are added in the order`Enumeration` returns them. * #### isLeaf public boolean isLeaf() Returns true if this node allows children. Whether the node allows children depends on how it was created. Specified by: `[isLeaf](../../javax/swing/tree/TreeNode.html#isLeaf--)` in interface `[TreeNode](../../javax/swing/tree/TreeNode.html "interface in javax.swing.tree")` Overrides: `[isLeaf](../../javax/swing/tree/DefaultMutableTreeNode.html#isLeaf--)` in class `[DefaultMutableTreeNode](../../javax/swing/tree/DefaultMutableTreeNode.html "class in javax.swing.tree")` Returns: true if this node allows children, false otherwise See Also: [JTree.DynamicUtilTreeNode](../../javax/swing/JTree.DynamicUtilTreeNode.html "class in javax.swing") * #### getChildCount public int getChildCount() Returns the number of child nodes. Specified by: `[getChildCount](../../javax/swing/tree/TreeNode.html#getChildCount--)` in interface `[TreeNode](../../javax/swing/tree/TreeNode.html "interface in javax.swing.tree")` Overrides: `[getChildCount](../../javax/swing/tree/DefaultMutableTreeNode.html#getChildCount--)` in class `[DefaultMutableTreeNode](../../javax/swing/tree/DefaultMutableTreeNode.html "class in javax.swing.tree")` Returns: the number of child nodes * #### loadChildren protected void loadChildren() Loads the children based on `childValue`. If `childValue` is a `Vector` or array each element is added as a child, if `childValue` is a `Hashtable` each key/value pair is added in the order that`Enumeration` returns the keys. * #### getChildAt public [TreeNode](../../javax/swing/tree/TreeNode.html "interface in javax.swing.tree") getChildAt(int index) Subclassed to load the children, if necessary. Specified by: `[getChildAt](../../javax/swing/tree/TreeNode.html#getChildAt-int-)` in interface `[TreeNode](../../javax/swing/tree/TreeNode.html "interface in javax.swing.tree")` Overrides: `[getChildAt](../../javax/swing/tree/DefaultMutableTreeNode.html#getChildAt-int-)` in class `[DefaultMutableTreeNode](../../javax/swing/tree/DefaultMutableTreeNode.html "class in javax.swing.tree")` Parameters: `index` \- an index into this node's child array Returns: the TreeNode in this node's child array at the specified index * #### children public [Enumeration](../../java/util/Enumeration.html "interface in java.util") children() Subclassed to load the children, if necessary. Specified by: `[children](../../javax/swing/tree/TreeNode.html#children--)` in interface `[TreeNode](../../javax/swing/tree/TreeNode.html "interface in javax.swing.tree")` Overrides: `[children](../../javax/swing/tree/DefaultMutableTreeNode.html#children--)` in class `[DefaultMutableTreeNode](../../javax/swing/tree/DefaultMutableTreeNode.html "class in javax.swing.tree")` Returns: an Enumeration of this node's children
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.