src/java.desktop/share/classes/javax/swing/tree/DefaultMutableTreeNode.java

Print this page




  78  * appropriate for short term storage or RMI between applications running
  79  * the same version of Swing.  As of 1.4, support for long term storage
  80  * of all JavaBeans™
  81  * has been added to the <code>java.beans</code> package.
  82  * Please see {@link java.beans.XMLEncoder}.
  83  *
  84  * @see MutableTreeNode
  85  *
  86  * @author Rob Davis
  87  */
  88 @SuppressWarnings("serial") // Same-version serialization only
  89 public class DefaultMutableTreeNode implements Cloneable,
  90        MutableTreeNode, Serializable
  91 {
  92     private static final long serialVersionUID = -4298474751201349152L;
  93 
  94     /**
  95      * An enumeration that is always empty. This is used when an enumeration
  96      * of a leaf node's children is requested.
  97      */
  98     static public final Enumeration<TreeNode> EMPTY_ENUMERATION
  99         = Collections.emptyEnumeration();
 100 
 101     /** this node's parent, or null if this node has no parent */
 102     protected MutableTreeNode   parent;
 103 
 104     /** array of children, may be null if this node has no children */
 105     protected Vector<TreeNode> children;
 106 
 107     /** optional user object */
 108     transient protected Object  userObject;
 109 
 110     /** true if the node is able to have children */
 111     protected boolean           allowsChildren;
 112 
 113 
 114     /**
 115      * Creates a tree node that has no parent and no children, but which
 116      * allows children.
 117      */
 118     public DefaultMutableTreeNode() {
 119         this(null);
 120     }
 121 
 122     /**
 123      * Creates a tree node with no parent, no children, but which allows
 124      * children, and initializes it with the specified user object.
 125      *
 126      * @param userObject an Object provided by the user that constitutes
 127      *                   the node's data
 128      */




  78  * appropriate for short term storage or RMI between applications running
  79  * the same version of Swing.  As of 1.4, support for long term storage
  80  * of all JavaBeans&trade;
  81  * has been added to the <code>java.beans</code> package.
  82  * Please see {@link java.beans.XMLEncoder}.
  83  *
  84  * @see MutableTreeNode
  85  *
  86  * @author Rob Davis
  87  */
  88 @SuppressWarnings("serial") // Same-version serialization only
  89 public class DefaultMutableTreeNode implements Cloneable,
  90        MutableTreeNode, Serializable
  91 {
  92     private static final long serialVersionUID = -4298474751201349152L;
  93 
  94     /**
  95      * An enumeration that is always empty. This is used when an enumeration
  96      * of a leaf node's children is requested.
  97      */
  98     public static final Enumeration<TreeNode> EMPTY_ENUMERATION
  99         = Collections.emptyEnumeration();
 100 
 101     /** this node's parent, or null if this node has no parent */
 102     protected MutableTreeNode   parent;
 103 
 104     /** array of children, may be null if this node has no children */
 105     protected Vector<TreeNode> children;
 106 
 107     /** optional user object */
 108     protected transient Object  userObject;
 109 
 110     /** true if the node is able to have children */
 111     protected boolean           allowsChildren;
 112 
 113 
 114     /**
 115      * Creates a tree node that has no parent and no children, but which
 116      * allows children.
 117      */
 118     public DefaultMutableTreeNode() {
 119         this(null);
 120     }
 121 
 122     /**
 123      * Creates a tree node with no parent, no children, but which allows
 124      * children, and initializes it with the specified user object.
 125      *
 126      * @param userObject an Object provided by the user that constitutes
 127      *                   the node's data
 128      */