public static class JTree.DynamicUtilTreeNode extends DefaultMutableTreeNode
DynamicUtilTreeNode 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.
protected boolean hasChildren
Does the this JTree have children? This property is currently not implemented.
protected Object childValue
Value to create children with.
protected boolean loadedChildren
Have the children been loaded yet?
public DynamicUtilTreeNode(Object value,
Object 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.
value - the Object that is the value for the new nodechildren - an array of Objects, 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 childrenpublic static void createChildren(DefaultMutableTreeNode parent,
Object 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.
public boolean isLeaf()
Returns true if this node allows children. Whether the node allows children depends on how it was created.
isLeaf in interface TreeNode
isLeaf in class DefaultMutableTreeNode
JTree.DynamicUtilTreeNodepublic int getChildCount()
Returns the number of child nodes.
getChildCount in interface TreeNode
getChildCount in class DefaultMutableTreeNode
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.
public TreeNode getChildAt(int index)
Subclassed to load the children, if necessary.
getChildAt in interface TreeNode
getChildAt in class DefaultMutableTreeNode
index - an index into this node's child arraypublic Enumeration children()
Subclassed to load the children, if necessary.
children in interface TreeNode
children in class DefaultMutableTreeNode
© 1993–2017, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.