1 /* 2 * Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package javax.swing.event; 27 28 import java.util.EventListener; 29 30 /** 31 * Defines the interface for an object that listens 32 * to changes in a TreeModel. 33 * For further information and examples see 34 * <a 35 href="http://java.sun.com/docs/books/tutorial/uiswing/events/treemodellistener.html">How to Write a Tree Model Listener</a>, 36 * a section in <em>The Java Tutorial.</em> 37 * 38 * @author Rob Davis 39 * @author Ray Ryan 40 */ 41 public interface TreeModelListener extends EventListener { 42 43 /** 44 * <p>Invoked after a node (or a set of siblings) has changed in some 45 * way. The node(s) have not changed locations in the tree or 46 * altered their children arrays, but other attributes have 47 * changed and may affect presentation. Example: the name of a 48 * file has changed, but it is in the same location in the file 49 * system.</p> 50 * <p>To indicate the root has changed, childIndices and children 51 * will be null. </p> 52 * 53 * <p>Use <code>e.getPath()</code> 54 * to get the parent of the changed node(s). 55 * <code>e.getChildIndices()</code> 56 * returns the index(es) of the changed node(s).</p> 57 */ 58 void treeNodesChanged(TreeModelEvent e); 59 60 /** 61 * <p>Invoked after nodes have been inserted into the tree.</p> 62 * 63 * <p>Use <code>e.getPath()</code> 64 * to get the parent of the new node(s). 65 * <code>e.getChildIndices()</code> 66 * returns the index(es) of the new node(s) 67 * in ascending order.</p> 68 */ 69 void treeNodesInserted(TreeModelEvent e); 70 71 /** 72 * <p>Invoked after nodes have been removed from the tree. Note that 73 * if a subtree is removed from the tree, this method may only be 74 * invoked once for the root of the removed subtree, not once for 75 * each individual set of siblings removed.</p> 76 * 77 * <p>Use <code>e.getPath()</code> 78 * to get the former parent of the deleted node(s). 79 * <code>e.getChildIndices()</code> 80 * returns, in ascending order, the index(es) 81 * the node(s) had before being deleted.</p> 82 */ 83 void treeNodesRemoved(TreeModelEvent e); 84 85 /** 86 * <p>Invoked after the tree has drastically changed structure from a 87 * given node down. If the path returned by e.getPath() is of length 88 * one and the first element does not identify the current root node 89 * the first element should become the new root of the tree.<p> 90 * 91 * <p>Use <code>e.getPath()</code> 92 * to get the path to the node. 93 * <code>e.getChildIndices()</code> 94 * returns null.</p> 95 */ 96 void treeStructureChanged(TreeModelEvent e); 97 98 }