DefaultTreeModel (Java SE 19 & JDK 19) (original) (raw)

All Implemented Interfaces:

[Serializable](../../../../java.base/java/io/Serializable.html "interface in java.io"), [TreeModel](TreeModel.html "interface in javax.swing.tree")


A simple tree data model that uses TreeNodes. For further information and examples that use DefaultTreeModel, see How to Use Trees in The Java Tutorial.

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.

Fields
protected boolean
Determines how the isLeaf method figures out if a node is a leaf node.

Constructors
Creates a tree in which any node can have children.
[DefaultTreeModel](#%3Cinit%3E%28javax.swing.tree.TreeNode,boolean%29)([TreeNode](TreeNode.html "interface in javax.swing.tree") root, boolean asksAllowsChildren)
Creates a tree specifying whether any node can have children, or whether only certain nodes can have children.

void
Adds a listener for the TreeModelEvent posted after the tree changes.
boolean
Tells how leaf nodes are determined.
protected void
Notifies all listeners that have registered interest for notification on this event type.
protected void
Notifies all listeners that have registered interest for notification on this event type.
protected void
Notifies all listeners that have registered interest for notification on this event type.
protected void
Notifies all listeners that have registered interest for notification on this event type.
[getChild](#getChild%28java.lang.Object,int%29)([Object](../../../../java.base/java/lang/Object.html "class in java.lang") parent, int index)
Returns the child of parent at index index in the parent's child array.
int
Returns the number of children of parent.
int
Returns the index of child in parent.
[getListeners](#getListeners%28java.lang.Class%29)([Class](../../../../java.base/java/lang/Class.html "class in java.lang")<T> listenerType)
Returns an array of all the objects currently registered as _Foo_Listeners upon this model.
Builds the parents of node up to and including the root node, where the original node is the last element in the returned array.
Builds the parents of node up to and including the root node, where the original node is the last element in the returned array.
[getRoot](#getRoot%28%29)()
Returns the root of the tree.
Returns an array of all the tree model listeners registered on this model.
void
Invoked this to insert newChild at location index in parents children.
boolean
Returns whether the specified node is a leaf node.
void
Invoke this method after you've changed how node is to be represented in the tree.
void
[nodesChanged](#nodesChanged%28javax.swing.tree.TreeNode,int%5B%5D%29)([TreeNode](TreeNode.html "interface in javax.swing.tree") node, int[] childIndices)
Invoke this method after you've changed how the children identified by childIndicies are to be represented in the tree.
void
Invoke this method if you've totally changed the children of node and its children's children...
void
Invoke this method after you've inserted some TreeNodes into node.
void
[nodesWereRemoved](#nodesWereRemoved%28javax.swing.tree.TreeNode,int%5B%5D,java.lang.Object%5B%5D%29)([TreeNode](TreeNode.html "interface in javax.swing.tree") node, int[] childIndices,[Object](../../../../java.base/java/lang/Object.html "class in java.lang")[] removedChildren)
Invoke this method after you've removed some TreeNodes from node.
void
[reload](#reload%28%29)()
Invoke this method if you've modified the TreeNodes upon which this model depends.
void
Invoke this method if you've modified the TreeNodes upon which this model depends.
void
Message this to remove node from its parent.
void
Removes a listener previously added with addTreeModelListener().
void
[setAsksAllowsChildren](#setAsksAllowsChildren%28boolean%29)(boolean newValue)
Sets whether or not to test leafness by asking getAllowsChildren() or isLeaf() to the TreeNodes.
void
void
This sets the user object of the TreeNode identified by path and posts a node changed.

Methods declared in class java.lang.Object

[clone](../../../../java.base/java/lang/Object.html#clone%28%29), [equals](../../../../java.base/java/lang/Object.html#equals%28java.lang.Object%29), [finalize](../../../../java.base/java/lang/Object.html#finalize%28%29), [getClass](../../../../java.base/java/lang/Object.html#getClass%28%29), [hashCode](../../../../java.base/java/lang/Object.html#hashCode%28%29), [notify](../../../../java.base/java/lang/Object.html#notify%28%29), [notifyAll](../../../../java.base/java/lang/Object.html#notifyAll%28%29), [toString](../../../../java.base/java/lang/Object.html#toString%28%29), [wait](../../../../java.base/java/lang/Object.html#wait%28%29), [wait](../../../../java.base/java/lang/Object.html#wait%28long%29), [wait](../../../../java.base/java/lang/Object.html#wait%28long,int%29)