home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VCafe / debug / databind.jar / javax / awt / swing / event / TreeModelEvent.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-03-19  |  2.9 KB  |  92 lines

  1. package javax.awt.swing.event;
  2.  
  3. import java.util.EventObject;
  4. import javax.awt.swing.tree.TreePath;
  5.  
  6. public class TreeModelEvent extends EventObject {
  7.    protected TreePath path;
  8.    protected int[] childIndices;
  9.    protected Object[] children;
  10.  
  11.    public TreeModelEvent(Object source, Object[] path, int[] childIndices, Object[] children) {
  12.       this(source, new TreePath(path), childIndices, children);
  13.    }
  14.  
  15.    public TreeModelEvent(Object source, Object[] path) {
  16.       this(source, new TreePath(path));
  17.    }
  18.  
  19.    public TreeModelEvent(Object source, TreePath path, int[] childIndices, Object[] children) {
  20.       super(source);
  21.       this.path = path;
  22.       this.childIndices = childIndices;
  23.       this.children = children;
  24.    }
  25.  
  26.    public TreeModelEvent(Object source, TreePath path) {
  27.       super(source);
  28.       this.path = path;
  29.       this.childIndices = new int[0];
  30.    }
  31.  
  32.    public TreePath getTreePath() {
  33.       return this.path;
  34.    }
  35.  
  36.    public Object[] getPath() {
  37.       return this.path != null ? this.path.getPath() : null;
  38.    }
  39.  
  40.    public Object[] getChildren() {
  41.       if (this.children != null) {
  42.          int cCount = this.children.length;
  43.          Object[] retChildren = new Object[cCount];
  44.          System.arraycopy(this.children, 0, retChildren, 0, cCount);
  45.          return retChildren;
  46.       } else {
  47.          return null;
  48.       }
  49.    }
  50.  
  51.    public int[] getChildIndices() {
  52.       if (this.childIndices != null) {
  53.          int cCount = this.childIndices.length;
  54.          int[] retArray = new int[cCount];
  55.          System.arraycopy(this.childIndices, 0, retArray, 0, cCount);
  56.          return retArray;
  57.       } else {
  58.          return null;
  59.       }
  60.    }
  61.  
  62.    public String toString() {
  63.       StringBuffer retBuffer = new StringBuffer();
  64.       retBuffer.append(this.getClass().getName() + " " + Integer.toString(this.hashCode()));
  65.       if (this.path != null) {
  66.          retBuffer.append(" path " + this.path);
  67.       }
  68.  
  69.       if (this.childIndices != null) {
  70.          retBuffer.append(" indicices [ ");
  71.  
  72.          for(int counter = 0; counter < this.childIndices.length; ++counter) {
  73.             retBuffer.append(Integer.toString(this.childIndices[counter]) + " ");
  74.          }
  75.  
  76.          retBuffer.append("]");
  77.       }
  78.  
  79.       if (this.children != null) {
  80.          retBuffer.append(" children [ ");
  81.  
  82.          for(int counter = 0; counter < this.children.length; ++counter) {
  83.             retBuffer.append(this.children[counter] + " ");
  84.          }
  85.  
  86.          retBuffer.append("]");
  87.       }
  88.  
  89.       return retBuffer.toString();
  90.    }
  91. }
  92.