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 java..
| Modifier and Type | Field and Description |
|---|---|
| protected boolean | asksAllowsChildren
Determines how the |
| protected EventListenerList | listenerList
Listeners. |
| protected TreeNode | root
Root of the tree. |
| Access | Constructor and Description |
|---|---|
| public | DefaultTreeModel(TreeNode
a TreeNode object that is the root of the tree root)Creates a tree in which any node can have children. |
| public | DefaultTreeModel(TreeNode
a TreeNode object that is the root of the tree root, boolean a boolean, false if any node can
have children, true if each node is asked to see if
it can have children asksAllowsChildren)Creates a tree specifying whether any node can have children, or whether only certain nodes can have children. |
| Modifier and Type | Method and Description |
|---|---|
| public void | addTreeModelListener(TreeModelListener
the listener to add l)Implements javax. Adds a listener for the TreeModelEvent posted after the tree changes. |
| public boolean | Returns: true if only nodes which do not allow children are leaf nodes, false if nodes which have no children (even if allowed) are leaf nodesTells how leaf nodes are determined. |
| protected void | fireTreeNodesChanged(Object
the source of the source, Object[] TreeModelEvent;
typically thisthe path to the parent of the nodes that changed; use
path, int[] null to identify the root has changedthe indices of the changed elements childIndices, Object[] the changed elements children)Notifies all listeners that have registered interest for notification on this event type. |
| protected void | fireTreeNodesInserted(Object
the source of the source, Object[] TreeModelEvent;
typically thisthe path to the parent the nodes were added to path, int[] the indices of the new elements childIndices, Object[] the new elements children)Notifies all listeners that have registered interest for notification on this event type. |
| protected void | fireTreeNodesRemoved(Object
the source of the source, Object[] TreeModelEvent;
typically thisthe path to the parent the nodes were removed from path, int[] the indices of the removed elements childIndices, Object[] the removed elements children)Notifies all listeners that have registered interest for notification on this event type. |
| protected void | fireTreeStructureChanged(Object
the source of the source, Object[] TreeModelEvent;
typically thisthe path to the parent of the structure that has changed;
use path, int[] null to identify the root has changedthe indices of the affected elements childIndices, Object[] the affected elements children)Notifies all listeners that have registered interest for notification on this event type. |
| private void | fireTreeStructureChanged(Object
the source of the source, TreePath TreeModelEvent;
typically thisthe path to the parent of the structure that has changed;
use path)null to identify the root has changedNotifies all listeners that have registered interest for notification on this event type. |
| public Object | Returns: the child of parent at index indexa node in the tree, obtained from this data source parent, int index)Implements javax. Returns the child of parent at index index in the parent's child array. |
| public int | Returns: the number of children of the node parenta node in the tree, obtained from this data source parent)Implements javax. Returns the number of children of parent. |
| public int | Returns: the index of the child in the parent, or -1 if either the parent or the child isnulla note in the tree, obtained from this data source parent, Object the node we are interested in child)Implements javax. Returns the index of child in parent. |
| public < the listener type T extends EventListener> T[] | Returns: an array of all objects registered asFooListeners on this component,
or an empty array if no such
listeners have been addedthe type of listeners requested listenerType)Returns an array of all the objects currently registered
as |
| public TreeNode[] | Returns: an array of TreeNodes giving the path from the rootthe TreeNode to get the path for aNode)Builds the parents of node up to and including the root node, where the original node is the last element in the returned array. |
| protected TreeNode[] | Returns: an array of TreeNodes giving the path from the root to the specified nodethe TreeNode to get the path for aNode, int an int giving the number of steps already taken towards
the root (on recursive calls), used to size the returned array depth)Builds the parents of node up to and including the root node, where the original node is the last element in the returned array. |
| public Object | Returns: the root of the treeImplements javax. Returns the root of the tree. |
| public TreeModelListener[] | Returns: all of this model'sTreeModelListeners
or an empty
array if no tree model listeners are currently registeredReturns an array of all the tree model listeners registered on this model. |
| public void | insertNodeInto(MutableTreeNode
child node to be inserted newChild, MutableTreeNode node to which children new node will be added parent, int index of parent's children index)Invoked this to insert newChild at location index in parents children. |
| public boolean | Returns: true if the node is a leaf nodethe node to check node)Implements javax. Returns whether the specified node is a leaf node. |
| public void | nodeChanged(TreeNode
the changed node node)Invoke this method after you've changed how node is to be represented in the tree. |
| public void | nodesChanged(TreeNode
changed node node, int[] indexes of changed children childIndices)Invoke this method after you've changed how the children identified by childIndices are to be represented in the tree. |
| public void | nodeStructureChanged(TreeNode
changed node node)Invoke this method if you've totally changed the children of node and its children's children... |
| public void | nodesWereInserted(TreeNode
parent node which children count been incremented node, int[] indexes of inserted children childIndices)Invoke this method after you've inserted some TreeNodes into node. |
| public void | nodesWereRemoved(TreeNode
parent node from which children were removed node, int[] indexes of removed children childIndices, Object[] array of the children objects that were removed removedChildren)Invoke this method after you've removed some TreeNodes from node. |
| private void | |
| public void | |
| public void | |
| public void | removeNodeFromParent(MutableTreeNode
the node to be removed from its parent node)Message this to remove node from its parent. |
| public void | removeTreeModelListener(TreeModelListener
the listener to remove l)Implements javax. Removes a listener previously added with addTreeModelListener(). |
| public void | setAsksAllowsChildren(boolean
if true, getAllowsChildren() is messaged, otherwise
isLeaf() is messaged newValue)Sets whether or not to test leafness by asking getAllowsChildren() or isLeaf() to the TreeNodes. |
| public void | |
| public void | valueForPathChanged(TreePath path, Object newValue)
Implements javax. This sets the user object of the TreeNode identified by path and posts a node changed. |
| private void |
| asksAllowsChildren | back to summary |
|---|---|
| protected boolean asksAllowsChildren Determines how the If this value is false, then any node which has no children is a leaf node, and any node may acquire children. | |
| listenerList | back to summary |
|---|---|
| protected EventListenerList listenerList Listeners. | |
| root | back to summary |
|---|---|
| protected TreeNode root Root of the tree. | |
| DefaultTreeModel | back to summary |
|---|---|
| public DefaultTreeModel(TreeNode root) Creates a tree in which any node can have children.
| |
| DefaultTreeModel | back to summary |
|---|---|
| public DefaultTreeModel(TreeNode root, boolean asksAllowsChildren) Creates a tree specifying whether any node can have children, or whether only certain nodes can have children.
| |
| addTreeModelListener | back to summary |
|---|---|
| public void addTreeModelListener(TreeModelListener l) Implements javax. Adds a listener for the TreeModelEvent posted after the tree changes.
| |
| asksAllowsChildren | back to summary |
|---|---|
| public boolean asksAllowsChildren() Tells how leaf nodes are determined.
| |
| fireTreeNodesChanged | back to summary |
|---|---|
| protected void fireTreeNodesChanged(Object source, Object[] path, int[] childIndices, Object[] children) Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method. | |
| fireTreeNodesInserted | back to summary |
|---|---|
| protected void fireTreeNodesInserted(Object source, Object[] path, int[] childIndices, Object[] children) Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method. | |
| fireTreeNodesRemoved | back to summary |
|---|---|
| protected void fireTreeNodesRemoved(Object source, Object[] path, int[] childIndices, Object[] children) Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method. | |
| fireTreeStructureChanged | back to summary |
|---|---|
| protected void fireTreeStructureChanged(Object source, Object[] path, int[] childIndices, Object[] children) Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method. | |
| fireTreeStructureChanged | back to summary |
|---|---|
| private void fireTreeStructureChanged(Object source, TreePath path) Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method. | |
| getChild | back to summary |
|---|---|
| public Object getChild(Object parent, int index) Implements javax. Returns the child of parent at index index in the parent's child array. parent must be a node previously obtained from this data source. This should not return null if index is a valid index for parent (that is index >= 0 && index < getChildCount(parent)). | |
| getChildCount | back to summary |
|---|---|
| public int getChildCount(Object parent) Implements javax. Returns the number of children of parent. Returns 0 if the node is a leaf or if it has no children. parent must be a node previously obtained from this data source.
| |
| getIndexOfChild | back to summary |
|---|---|
| public int getIndexOfChild(Object parent, Object child) Implements javax. Returns the index of child in parent.
If either the parent or child is | |
| getListeners | back to summary |
|---|---|
| public <T extends EventListener> T[] getListeners(Class<T> listenerType) Returns an array of all the objects currently registered
as
You can specify the TreeModelListener[] tmls = (TreeModelListener[])(m.getListeners(TreeModelListener.class));If no such listeners exist, this method returns an empty array.
| |
| getPathToRoot | back to summary |
|---|---|
| public TreeNode[] getPathToRoot(TreeNode aNode) Builds the parents of node up to and including the root node, where the original node is the last element in the returned array. The length of the returned array gives the node's depth in the tree. | |
| getPathToRoot | back to summary |
|---|---|
| protected TreeNode[] getPathToRoot(TreeNode aNode, int depth) Builds the parents of node up to and including the root node, where the original node is the last element in the returned array. The length of the returned array gives the node's depth in the tree. | |
| getRoot | back to summary |
|---|---|
| public Object getRoot() Implements javax. Returns the root of the tree. Returns null only if the tree has no nodes.
| |
| getTreeModelListeners | back to summary |
|---|---|
| public TreeModelListener[] getTreeModelListeners() Returns an array of all the tree model listeners registered on this model.
| |
| insertNodeInto | back to summary |
|---|---|
| public void insertNodeInto(MutableTreeNode newChild, MutableTreeNode parent, int index) Invoked this to insert newChild at location index in parents children. This will then message nodesWereInserted to create the appropriate event. This is the preferred way to add children as it will create the appropriate event.
| |
| isLeaf | back to summary |
|---|---|
| public boolean isLeaf(Object node) Implements javax. Returns whether the specified node is a leaf node.
The way the test is performed depends on the
| |
| nodeChanged | back to summary |
|---|---|
| public void nodeChanged(TreeNode node) Invoke this method after you've changed how node is to be represented in the tree.
| |
| nodesChanged | back to summary |
|---|---|
| public void nodesChanged(TreeNode node, int[] childIndices) Invoke this method after you've changed how the children identified by childIndices are to be represented in the tree.
| |
| nodeStructureChanged | back to summary |
|---|---|
| public void nodeStructureChanged(TreeNode node) Invoke this method if you've totally changed the children of node and its children's children... This will post a treeStructureChanged event.
| |
| nodesWereInserted | back to summary |
|---|---|
| public void nodesWereInserted(TreeNode node, int[] childIndices) Invoke this method after you've inserted some TreeNodes into node. childIndices should be the index of the new elements and must be sorted in ascending order.
| |
| nodesWereRemoved | back to summary |
|---|---|
| public void nodesWereRemoved(TreeNode node, int[] childIndices, Object[] removedChildren) Invoke this method after you've removed some TreeNodes from node. childIndices should be the index of the removed elements and must be sorted in ascending order. And removedChildren should be the array of the children objects that were removed. | |
| readObject | back to summary |
|---|---|
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException
| |
| reload | back to summary |
|---|---|
| public void reload() Invoke this method if you've modified the | |
| reload | back to summary |
|---|---|
| public void reload(TreeNode node) Invoke this method if you've modified the
| |
| removeNodeFromParent | back to summary |
|---|---|
| public void removeNodeFromParent(MutableTreeNode node) Message this to remove node from its parent. This will message nodesWereRemoved to create the appropriate event. This is the preferred way to remove a node as it handles the event creation for you.
| |
| removeTreeModelListener | back to summary |
|---|---|
| public void removeTreeModelListener(TreeModelListener l) Implements javax. Removes a listener previously added with addTreeModelListener().
| |
| setAsksAllowsChildren | back to summary |
|---|---|
| public void setAsksAllowsChildren(boolean newValue) Sets whether or not to test leafness by asking getAllowsChildren() or isLeaf() to the TreeNodes. If newvalue is true, getAllowsChildren() is messaged, otherwise isLeaf() is messaged.
| |
| setRoot | back to summary |
|---|---|
| public void setRoot(TreeNode root) Sets the root to
| |
| valueForPathChanged | back to summary |
|---|---|
| public void valueForPathChanged(TreePath path, Object newValue) Implements javax. This sets the user object of the TreeNode identified by path and posts a node changed. If you use custom user objects in the TreeModel you're going to need to subclass this and set the user object of the changed node to something meaningful. | |
| writeObject | back to summary |
|---|---|
private void writeObject(ObjectOutputStream s) throws IOException
| |