1 15 16 package swingwtx.swing.event; 17 18 import swingwtx.swing.tree.*; 19 20 public class TreeModelEvent extends java.util.EventObject { 21 22 protected TreePath path; 23 protected int[] childIndices; 24 protected Object [] children; 25 26 public TreeModelEvent(Object source, Object [] path, int[] childIndices, 27 Object [] children) 28 { 29 this(source, new TreePath(path), childIndices, children); 30 } 31 32 public TreeModelEvent(Object source, TreePath path, int[] childIndices, 33 Object [] children) 34 { 35 super(source); 36 this.path = path; 37 this.childIndices = childIndices; 38 this.children = children; 39 } 40 41 public TreeModelEvent(Object source, Object [] path) 42 { 43 this(source, new TreePath(path)); 44 } 45 46 public TreeModelEvent(Object source, TreePath path) 47 { 48 super(source); 49 this.path = path; 50 this.childIndices = new int[0]; 51 } 52 53 public TreePath getTreePath() { return path; } 54 55 public Object [] getPath() { 56 if(path != null) 57 return path.getPath(); 58 return null; 59 } 60 61 public Object [] getChildren() { 62 if(children != null) { 63 int cCount = children.length; 64 Object [] retChildren = new Object [cCount]; 65 66 System.arraycopy(children, 0, retChildren, 0, cCount); 67 return retChildren; 68 } 69 return null; 70 } 71 72 public int[] getChildIndices() { 73 if(childIndices != null) { 74 int cCount = childIndices.length; 75 int[] retArray = new int[cCount]; 76 77 System.arraycopy(childIndices, 0, retArray, 0, cCount); 78 return retArray; 79 } 80 return null; 81 } 82 83 public String toString() { 84 StringBuffer retBuffer = new StringBuffer (); 85 86 retBuffer.append(getClass().getName() + " " + 87 Integer.toString(hashCode())); 88 if(path != null) 89 retBuffer.append(" path " + path); 90 if(childIndices != null) { 91 retBuffer.append(" indices [ "); 92 for(int counter = 0; counter < childIndices.length; counter++) 93 retBuffer.append(Integer.toString(childIndices[counter])+ " "); 94 retBuffer.append("]"); 95 } 96 if(children != null) { 97 retBuffer.append(" children [ "); 98 for(int counter = 0; counter < children.length; counter++) 99 retBuffer.append(children[counter] + " "); 100 retBuffer.append("]"); 101 } 102 return retBuffer.toString(); 103 } 104 } 105 | Popular Tags |