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