JTree.DynamicUtilTreeNode (Java 2 Platform SE 5.0) (original) (raw)
javax.swing
Class JTree.DynamicUtilTreeNode
java.lang.Object
javax.swing.tree.DefaultMutableTreeNode
javax.swing.JTree.DynamicUtilTreeNode
All Implemented Interfaces:
Serializable, Cloneable, MutableTreeNode, TreeNode
Enclosing class:
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 JavaBeansTM has been added to the java.beans
package. Please see XMLEncoder.
Field Summary | |
---|---|
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 |
---|
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject |
Constructor Summary |
---|
[JTree.DynamicUtilTreeNode](../../javax/swing/JTree.DynamicUtilTreeNode.html#JTree.DynamicUtilTreeNode%28java.lang.Object, java.lang.Object%29)(Object value,Object children) Creates a node with the specified object as its value and with the specified children. |
Method Summary | |
---|---|
Enumeration | children() Subclassed to load the children, if necessary. |
static void | [createChildren](../../javax/swing/JTree.DynamicUtilTreeNode.html#createChildren%28javax.swing.tree.DefaultMutableTreeNode, java.lang.Object%29)(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 |
---|
add, breadthFirstEnumeration, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildBefore, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, [getPathToRoot](../../javax/swing/tree/DefaultMutableTreeNode.html#getPathToRoot%28javax.swing.tree.TreeNode, int%29), getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, [insert](../../javax/swing/tree/DefaultMutableTreeNode.html#insert%28javax.swing.tree.MutableTreeNode, int%29), isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject, toString |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, [wait](../../java/lang/Object.html#wait%28long, int%29) |
Field Detail |
---|
hasChildren
protected boolean hasChildren
Does the this JTree
have children? This property is currently not implemented.
childValue
protected Object childValue
Value to create children with.
loadedChildren
protected boolean loadedChildren
Have the children been loaded yet?
Constructor Detail |
---|
JTree.DynamicUtilTreeNode
public JTree.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, aVector
, 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, aVector
, or a Hashtable
used to create the child nodes; if any other object is specified, or if the value isnull
, then the node is not allowed to have children
Method Detail |
---|
createChildren
public 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 orderEnumeration
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%28%29)
in interface [TreeNode](../../javax/swing/tree/TreeNode.html "interface in javax.swing.tree")
Overrides:
[isLeaf](../../javax/swing/tree/DefaultMutableTreeNode.html#isLeaf%28%29)
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(java.lang.Object, java.lang.Object)](../../javax/swing/JTree.DynamicUtilTreeNode.html#JTree.DynamicUtilTreeNode%28java.lang.Object, java.lang.Object%29)
getChildCount
public int getChildCount()
Returns the number of child nodes.
Specified by:
[getChildCount](../../javax/swing/tree/TreeNode.html#getChildCount%28%29)
in interface [TreeNode](../../javax/swing/tree/TreeNode.html "interface in javax.swing.tree")
Overrides:
[getChildCount](../../javax/swing/tree/DefaultMutableTreeNode.html#getChildCount%28%29)
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 thatEnumeration
returns the keys.
getChildAt
public TreeNode getChildAt(int index)
Subclassed to load the children, if necessary.
Specified by:
[getChildAt](../../javax/swing/tree/TreeNode.html#getChildAt%28int%29)
in interface [TreeNode](../../javax/swing/tree/TreeNode.html "interface in javax.swing.tree")
Overrides:
[getChildAt](../../javax/swing/tree/DefaultMutableTreeNode.html#getChildAt%28int%29)
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 children()
Subclassed to load the children, if necessary.
Specified by:
[children](../../javax/swing/tree/TreeNode.html#children%28%29)
in interface [TreeNode](../../javax/swing/tree/TreeNode.html "interface in javax.swing.tree")
Overrides:
[children](../../javax/swing/tree/DefaultMutableTreeNode.html#children%28%29)
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 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2004, 2010 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.