Class JTree.DynamicUtilTreeNode
java.lang.Object
javax.swing.tree.DefaultMutableTreeNode
javax.swing.JTree.DynamicUtilTreeNode
- All Implemented Interfaces:
- Serializable, Cloneable, MutableTreeNode, TreeNode
- Enclosing class:
- JTree
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.
- Since:
- 1.2
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected ObjectValue to create children with.protected booleanDoes the thisJTreehave children?protected booleanHave the children been loaded yet?Fields declared in class DefaultMutableTreeNodeallowsChildren, children, EMPTY_ENUMERATION, parent, userObject
- 
Constructor SummaryConstructorsConstructorDescriptionDynamicUtilTreeNode(Object value, Object children) Creates a node with the specified object as its value and with the specified children.
- 
Method SummaryModifier and TypeMethodDescriptionchildren()Subclassed to load the children, if necessary.static voidcreateChildren(DefaultMutableTreeNode parent, Object children) Adds to parent all the children inchildren.getChildAt(int index) Subclassed to load the children, if necessary.intReturns the number of child nodes.booleanisLeaf()Returns true if this node allows children.protected voidLoads the children based onchildValue.Methods declared in class DefaultMutableTreeNodeadd, breadthFirstEnumeration, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildBefore, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, insert, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject, toString
- 
Field Details- 
hasChildrenprotected boolean hasChildrenDoes the thisJTreehave children? This property is currently not implemented.
- 
childValueValue to create children with.
- 
loadedChildrenprotected boolean loadedChildrenHave the children been loaded yet?
 
- 
- 
Constructor Details- 
DynamicUtilTreeNodeCreates 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, aVector, or aHashtable-- even if empty. Otherwise, the node is not allowed to have children.- Parameters:
- value- the- Objectthat is the value for the new node
- children- an array of- Objects, a- Vector, or a- Hashtableused 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 Details- 
createChildrenAdds to parent all the children inchildren. Ifchildrenis an array or vector all of its elements are added is children, otherwise ifchildrenis a hashtable all the key/value pairs are added in the orderEnumerationreturns them.- Parameters:
- parent- the parent node
- children- the children
 
- 
isLeafpublic boolean isLeaf()Returns true if this node allows children. Whether the node allows children depends on how it was created.- Specified by:
- isLeafin interface- TreeNode
- Overrides:
- isLeafin class- DefaultMutableTreeNode
- Returns:
- true if this node allows children, false otherwise
- See Also:
 
- 
getChildCountpublic int getChildCount()Returns the number of child nodes.- Specified by:
- getChildCountin interface- TreeNode
- Overrides:
- getChildCountin class- DefaultMutableTreeNode
- Returns:
- the number of child nodes
 
- 
loadChildrenprotected void loadChildren()Loads the children based onchildValue. IfchildValueis aVectoror array each element is added as a child, ifchildValueis aHashtableeach key/value pair is added in the order thatEnumerationreturns the keys.
- 
getChildAtSubclassed to load the children, if necessary.- Specified by:
- getChildAtin interface- TreeNode
- Overrides:
- getChildAtin class- DefaultMutableTreeNode
- Parameters:
- index- an index into this node's child array
- Returns:
- the TreeNode in this node's child array at the specified index
 
- 
childrenSubclassed to load the children, if necessary.- Specified by:
- childrenin interface- TreeNode
- Overrides:
- childrenin class- DefaultMutableTreeNode
- Returns:
- an Enumeration of this node's children
 
 
-