All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.java.swing.tree.DefaultTreeModel

java.lang.Object
   |
   +----com.sun.java.swing.tree.DefaultTreeModel

public class DefaultTreeModel
extends Object
implements Serializable, TreeModel
A simple tree data model that uses TreeNodes.

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 Swing1.0 applications. It will not be possible to load serialized Swing1.0 objects with future releases of Swing. The JDK1.2 release of Swing will be the compatibility baseline for the serialized form of Swing objects.


Variable Index

 o asksAllowsChildren
Determines how the isLeaf determines if a node is a leaf node.
 o listenerList
Listeners.
 o root
Root of the tree.

Constructor Index

 o DefaultTreeModel(TreeNode)
 o DefaultTreeModel(TreeNode, boolean)

Method Index

 o addTreeModelListener(TreeModelListener)
 o asksAllowsChildren()
Tells how leaf nodes are determined.
 o fireTreeNodesChanged(Object, Object[], int[], Object[])
 o fireTreeNodesInserted(Object, Object[], int[], Object[])
 o fireTreeNodesRemoved(Object, Object[], int[], Object[])
 o fireTreeStructureChanged(Object, Object[], int[], Object[])
 o getChild(Object, int)
 o getChildCount(Object)
 o getIndexOfChild(Object, Object)
 o getPathToRoot(TreeNode)
Builds the parents of child up to, and including, the root node.
 o getPathToRoot(TreeNode, int)
 o getRoot()
 o insertNodeInto(MutableTreeNode, MutableTreeNode, int)
Invoked this to insert newChild at location index in parents children.
 o isLeaf(Object)
Returns whether the specified node is a leaf node.
 o nodeChanged(TreeNode)
Invoke this method after you've changed how node is to be represented in the tree.
 o nodesChanged(TreeNode, int[])
Invoke this method after you've changed how the children identified by childIndicies are to be represented in the tree.
 o nodeStructureChanged(TreeNode)
Invoke this method if you've totally changed the children of node and its childrens children...
 o nodesWereInserted(TreeNode, int[])
Invoke this method after you've inserted some TreeNodes into node.
 o nodesWereRemoved(TreeNode, int[], Object[])
Invoke this method after you've removed some TreeNodes from node.
 o reload()
Invoke this method if you've modified the TreeNodes upon which this model depends.
 o reload(TreeNode)
Invoke this method if you've modified the TreeNodes upon which this model depends.
 o removeNodeFromParent(MutableTreeNode)
Message this to remove node from its parent.
 o removeTreeModelListener(TreeModelListener)
 o setAsksAllowsChildren(boolean)
Sets whether or not to test leafness by asking getAllowsChildren() or isLeaf() to the TreeNodes.
 o valueForPathChanged(TreePath, Object)
This sets the user object of the TreeNode identified by path and posts a node changed.

Variables

 o root
 protected TreeNode root
Root of the tree.

 o listenerList
 protected EventListenerList listenerList
Listeners.

 o asksAllowsChildren
 protected boolean asksAllowsChildren
Determines how the isLeaf determines if a node is a leaf node. If true, a node is a leaf node if it does not allow children. (If it allows children, it is not a leaf node, even if no children are present.) If this value is false, then any node which has no children is a leaf node.

See Also:
getAllowsChildren, isLeaf, setAsksAllowsChildren

Constructors

 o DefaultTreeModel
 public DefaultTreeModel(TreeNode root)
 o DefaultTreeModel
 public DefaultTreeModel(TreeNode root,
                         boolean asksAllowsChildren)

Methods

 o setAsksAllowsChildren
 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.

 o asksAllowsChildren
 public boolean asksAllowsChildren()
Tells how leaf nodes are determined.

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 nodes
See Also:
askAllowsChildren
 o getRoot
 public Object getRoot()
 o getIndexOfChild
 public int getIndexOfChild(Object parent,
                            Object child)
 o getChild
 public Object getChild(Object parent,
                        int index)
 o getChildCount
 public int getChildCount(Object parent)
 o isLeaf
 public boolean isLeaf(Object node)
Returns whether the specified node is a leaf node. The way the test is performed depends on the askAllowsChildren setting.

Parameters:
node - the node to check
Returns:
true if the node is a leaf node
See Also:
askAllowsChildren, isLeaf
 o reload
 public void reload()
Invoke this method if you've modified the TreeNodes upon which this model depends. The model will notify all of its listeners that the model has changed.

 o valueForPathChanged
 public void valueForPathChanged(TreePath path,
                                 Object newValue)
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.

 o insertNodeInto
 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.

 o removeNodeFromParent
 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.

 o nodeChanged
 public void nodeChanged(TreeNode node)
Invoke this method after you've changed how node is to be represented in the tree.

 o reload
 public void reload(TreeNode node)
Invoke this method if you've modified the TreeNodes upon which this model depends. The model will notify all of its listeners that the model has changed below the node node (PENDING).

 o nodesWereInserted
 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.

 o nodesWereRemoved
 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.

 o nodesChanged
 public void nodesChanged(TreeNode node,
                          int childIndices[])
Invoke this method after you've changed how the children identified by childIndicies are to be represented in the tree.

 o nodeStructureChanged
 public void nodeStructureChanged(TreeNode node)
Invoke this method if you've totally changed the children of node and its childrens children... This will post a treeStructureChanged event.

 o getPathToRoot
 public TreeNode[] getPathToRoot(TreeNode child)
Builds the parents of child up to, and including, the root node. child will be the last element in the returned array.

 o getPathToRoot
 protected TreeNode[] getPathToRoot(TreeNode aNode,
                                    int depth)
 o addTreeModelListener
 public void addTreeModelListener(TreeModelListener l)
 o removeTreeModelListener
 public void removeTreeModelListener(TreeModelListener l)
 o fireTreeNodesChanged
 protected void fireTreeNodesChanged(Object source,
                                     Object path[],
                                     int childIndices[],
                                     Object children[])
 o fireTreeNodesInserted
 protected void fireTreeNodesInserted(Object source,
                                      Object path[],
                                      int childIndices[],
                                      Object children[])
 o fireTreeNodesRemoved
 protected void fireTreeNodesRemoved(Object source,
                                     Object path[],
                                     int childIndices[],
                                     Object children[])
 o fireTreeStructureChanged
 protected void fireTreeStructureChanged(Object source,
                                         Object path[],
                                         int childIndices[],
                                         Object children[])

All Packages  Class Hierarchy  This Package  Previous  Next  Index