Class SampleTreeModel

  extended by javax.swing.tree.DefaultTreeModel
      extended by
All Implemented Interfaces:, javax.swing.tree.TreeModel

public class SampleTreeModel
extends javax.swing.tree.DefaultTreeModel

SampleTreeModel extends JTreeModel to extends valueForPathChanged. This method is called as a result of the user editing a value in the tree. If you allow editing in your tree, are using TreeNodes and the user object of the TreeNodes is not a String, then you're going to have to subclass JTreeModel as this example does.

See Also:
Serialized Form

Field Summary
Fields inherited from class javax.swing.tree.DefaultTreeModel
asksAllowsChildren, listenerList, root
Constructor Summary
SampleTreeModel(javax.swing.tree.TreeNode newRoot)
Method Summary
 void valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)
          Subclassed to message setString() to the changed path item.
Methods inherited from class javax.swing.tree.DefaultTreeModel
addTreeModelListener, asksAllowsChildren, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getChild, getChildCount, getIndexOfChild, getListeners, getPathToRoot, getPathToRoot, getRoot, getTreeModelListeners, insertNodeInto, isLeaf, nodeChanged, nodesChanged, nodeStructureChanged, nodesWereInserted, nodesWereRemoved, reload, reload, removeNodeFromParent, removeTreeModelListener, setAsksAllowsChildren, setRoot
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public SampleTreeModel(javax.swing.tree.TreeNode newRoot)
Method Detail


public void valueForPathChanged(javax.swing.tree.TreePath path,
                                java.lang.Object newValue)
Subclassed to message setString() to the changed path item.

Specified by:
valueForPathChanged in interface javax.swing.tree.TreeModel
valueForPathChanged in class javax.swing.tree.DefaultTreeModel