1. /*
  2. * @(#)TreeModelListener.java 1.17 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.swing.event;
  8. import java.util.EventListener;
  9. /**
  10. * Defines the interface for an object that listens
  11. * to changes in a TreeModel.
  12. * For further information and examples see
  13. * <a
  14. href="http://java.sun.com/docs/books/tutorial/uiswing/events/treemodellistener.html">How to Write a Tree Model Listener</a>,
  15. * a section in <em>The Java Tutorial.</em>
  16. *
  17. * @version 1.17 12/19/03
  18. * @author Rob Davis
  19. * @author Ray Ryan
  20. */
  21. public interface TreeModelListener extends EventListener {
  22. /**
  23. * <p>Invoked after a node (or a set of siblings) has changed in some
  24. * way. The node(s) have not changed locations in the tree or
  25. * altered their children arrays, but other attributes have
  26. * changed and may affect presentation. Example: the name of a
  27. * file has changed, but it is in the same location in the file
  28. * system.</p>
  29. * <p>To indicate the root has changed, childIndices and children
  30. * will be null. </p>
  31. *
  32. * <p>Use <code>e.getPath()</code>
  33. * to get the parent of the changed node(s).
  34. * <code>e.getChildIndices()</code>
  35. * returns the index(es) of the changed node(s).</p>
  36. */
  37. void treeNodesChanged(TreeModelEvent e);
  38. /**
  39. * <p>Invoked after nodes have been inserted into the tree.</p>
  40. *
  41. * <p>Use <code>e.getPath()</code>
  42. * to get the parent of the new node(s).
  43. * <code>e.getChildIndices()</code>
  44. * returns the index(es) of the new node(s)
  45. * in ascending order.</p>
  46. */
  47. void treeNodesInserted(TreeModelEvent e);
  48. /**
  49. * <p>Invoked after nodes have been removed from the tree. Note that
  50. * if a subtree is removed from the tree, this method may only be
  51. * invoked once for the root of the removed subtree, not once for
  52. * each individual set of siblings removed.</p>
  53. *
  54. * <p>Use <code>e.getPath()</code>
  55. * to get the former parent of the deleted node(s).
  56. * <code>e.getChildIndices()</code>
  57. * returns, in ascending order, the index(es)
  58. * the node(s) had before being deleted.</p>
  59. */
  60. void treeNodesRemoved(TreeModelEvent e);
  61. /**
  62. * <p>Invoked after the tree has drastically changed structure from a
  63. * given node down. If the path returned by e.getPath() is of length
  64. * one and the first element does not identify the current root node
  65. * the first element should become the new root of the tree.<p>
  66. *
  67. * <p>Use <code>e.getPath()</code>
  68. * to get the path to the node.
  69. * <code>e.getChildIndices()</code>
  70. * returns null.</p>
  71. */
  72. void treeStructureChanged(TreeModelEvent e);
  73. }