1 7 8 package javax.swing.event; 9 10 import java.util.EventObject ; 11 import javax.swing.tree.TreePath ; 12 13 14 36 public class TreeModelEvent extends EventObject { 37 38 protected TreePath path; 39 40 protected int[] childIndices; 41 42 protected Object [] children; 43 44 111 public TreeModelEvent(Object source, Object [] path, int[] childIndices, 112 Object [] children) 113 { 114 this(source, new TreePath (path), childIndices, children); 115 } 116 117 136 public TreeModelEvent(Object source, TreePath path, int[] childIndices, 137 Object [] children) 138 { 139 super(source); 140 this.path = path; 141 this.childIndices = childIndices; 142 this.children = children; 143 } 144 145 167 public TreeModelEvent(Object source, Object [] path) 168 { 169 this(source, new TreePath (path)); 170 } 171 172 189 public TreeModelEvent(Object source, TreePath path) 190 { 191 super(source); 192 this.path = path; 193 this.childIndices = new int[0]; 194 } 195 196 211 public TreePath getTreePath() { return path; } 212 213 221 public Object [] getPath() { 222 if(path != null) 223 return path.getPath(); 224 return null; 225 } 226 227 238 public Object [] getChildren() { 239 if(children != null) { 240 int cCount = children.length; 241 Object [] retChildren = new Object [cCount]; 242 243 System.arraycopy(children, 0, retChildren, 0, cCount); 244 return retChildren; 245 } 246 return null; 247 } 248 249 259 public int[] getChildIndices() { 260 if(childIndices != null) { 261 int cCount = childIndices.length; 262 int[] retArray = new int[cCount]; 263 264 System.arraycopy(childIndices, 0, retArray, 0, cCount); 265 return retArray; 266 } 267 return null; 268 } 269 270 276 public String toString() { 277 StringBuffer retBuffer = new StringBuffer (); 278 279 retBuffer.append(getClass().getName() + " " + 280 Integer.toString(hashCode())); 281 if(path != null) 282 retBuffer.append(" path " + path); 283 if(childIndices != null) { 284 retBuffer.append(" indices [ "); 285 for(int counter = 0; counter < childIndices.length; counter++) 286 retBuffer.append(Integer.toString(childIndices[counter])+ " "); 287 retBuffer.append("]"); 288 } 289 if(children != null) { 290 retBuffer.append(" children [ "); 291 for(int counter = 0; counter < children.length; counter++) 292 retBuffer.append(children[counter] + " "); 293 retBuffer.append("]"); 294 } 295 return retBuffer.toString(); 296 } 297 } 298 | Popular Tags |