- java.lang.Object
-
- javax.swing.tree.DefaultMutableTreeNode
-
- javax.swing.JTree.DynamicUtilTreeNode
-
- All Implemented Interfaces:
- Serializable, Cloneable, MutableTreeNode, TreeNode
- Enclosing class:
- JTree
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 seeXMLEncoder
.
-
-
Field Summary
Fields Modifier and Type Field and Description protected Object
childValue
Value to create children with.protected boolean
hasChildren
Does the thisJTree
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
Constructors Constructor and Description JTree.DynamicUtilTreeNode(Object value, Object children)
Creates a node with the specified object as its value and with the specified children.
-
Method Summary
Methods Modifier and Type Method and Description Enumeration
children()
Subclassed to load the children, if necessary.static void
createChildren(DefaultMutableTreeNode parent, Object children)
Adds to parent all the children inchildren
.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 onchildValue
.-
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, 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 Detail
-
hasChildren
protected boolean hasChildren
Does the thisJTree
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 aHashtable
-- even if empty. Otherwise, the node is not allowed to have children.- Parameters:
value
- theObject
that is the value for the new nodechildren
- an array ofObject
s, aVector
, or aHashtable
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 inchildren
. Ifchildren
is an array or vector all of its elements are added is children, otherwise ifchildren
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
in interfaceTreeNode
- Overrides:
isLeaf
in classDefaultMutableTreeNode
- Returns:
- true if this node allows children, false otherwise
- See Also:
JTree.DynamicUtilTreeNode(java.lang.Object, java.lang.Object)
-
getChildCount
public int getChildCount()
Returns the number of child nodes.- Specified by:
getChildCount
in interfaceTreeNode
- Overrides:
getChildCount
in classDefaultMutableTreeNode
- Returns:
- the number of child nodes
-
loadChildren
protected void loadChildren()
Loads the children based onchildValue
. IfchildValue
is aVector
or array each element is added as a child, ifchildValue
is aHashtable
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
in interfaceTreeNode
- Overrides:
getChildAt
in classDefaultMutableTreeNode
- 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
in interfaceTreeNode
- Overrides:
children
in classDefaultMutableTreeNode
- Returns:
- an Enumeration of this node's children
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-javax/swing/jtree.dynamicutiltreenode.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.