📄 defaultmutabletreenode.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Thu Apr 27 23:42:46 PDT 2000 --><TITLE>Java 2 Platform SE v1.3: Class DefaultMutableTreeNode</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/DefaultMutableTreeNode.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../javax/swing/tree/AbstractLayoutCache.NodeDimensions.html"><B>PREV CLASS</B></A> <A HREF="../../../javax/swing/tree/DefaultTreeCellEditor.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="DefaultMutableTreeNode.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">javax.swing.tree</FONT><BR>Class DefaultMutableTreeNode</H2><PRE><A HREF="../../../java/lang/Object.html">java.lang.Object</A> | +--<B>javax.swing.tree.DefaultMutableTreeNode</B></PRE><DL><DT><B>All Implemented Interfaces:</B> <DD><A HREF="../../../java/lang/Cloneable.html">Cloneable</A>, <A HREF="../../../javax/swing/tree/MutableTreeNode.html">MutableTreeNode</A>, <A HREF="../../../java/io/Serializable.html">Serializable</A>, <A HREF="../../../javax/swing/tree/TreeNode.html">TreeNode</A></DD></DL><DL><DT><B>Direct Known Subclasses:</B> <DD><A HREF="../../../javax/swing/JTree.DynamicUtilTreeNode.html">JTree.DynamicUtilTreeNode</A></DD></DL><HR><DL><DT>public class <B>DefaultMutableTreeNode</B><DT>extends <A HREF="../../../java/lang/Object.html">Object</A><DT>implements <A HREF="../../../java/lang/Cloneable.html">Cloneable</A>, <A HREF="../../../javax/swing/tree/MutableTreeNode.html">MutableTreeNode</A>, <A HREF="../../../java/io/Serializable.html">Serializable</A></DL><P>A <code>DefaultMutableTreeNode</code> is a general-purpose node in a tree data structure. For examples of using default mutable tree nodes, see <ahref="http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html">How to Use Trees</a> in <em>The Java Tutorial.</em> <p> A tree node may have at most one parent and 0 or more children. <code>DefaultMutableTreeNode</code> provides operations for examining and modifying a node's parent and children and also operations for examining the tree that the node is a part of. A node's tree is the set of all nodes that can be reached by starting at the node and following all the possible links to parents and children. A node with no parent is the root of its tree; a node with no children is a leaf. A tree may consist of many subtrees, each node acting as the root for its own subtree. <p> This class provides enumerations for efficiently traversing a tree or subtree in various orders or for following the path between two nodes. A <code>DefaultMutableTreeNode</code> may also hold a reference to a user object, the use of which is left to the user. Asking a <code>DefaultMutableTreeNode</code> for its string representation with <code>toString()</code> returns the string representation of its user object. <p> <b>This is not a thread safe class.</b>If you intend to use a DefaultMutableTreeNode (or a tree of TreeNodes) in more than one thread, you need to do your own synchronizing. A good convention to adopt is synchronizing on the root node of a tree. <p> While DefaultMutableTreeNode implements the MutableTreeNode interface and will allow you to add in any implementation of MutableTreeNode not all of the methods in DefaultMutableTreeNode will be applicable to all MutableTreeNodes implementations. Especially with some of the enumerations that are provided, using some of these methods assumes the DefaultMutableTreeNode contains only DefaultMutableNode instances. All of the TreeNode/MutableTreeNode methods will behave as defined no matter what implementations are added. <p> <strong>Warning:</strong> Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.<P><DL><DT><B>See Also: </B><DD><A HREF="../../../javax/swing/tree/MutableTreeNode.html"><CODE>MutableTreeNode</CODE></A>, <A HREF="../../../serialized-form.html#javax.swing.tree.DefaultMutableTreeNode">Serialized Form</A></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><A NAME="field_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Field Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/swing/tree/DefaultMutableTreeNode.html#allowsChildren">allowsChildren</A></B></CODE><BR> true if the node is able to have children</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected <A HREF="../../../java/util/Vector.html">Vector</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/swing/tree/DefaultMutableTreeNode.html#children">children</A></B></CODE><BR> array of children, may be null if this node has no children</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../../java/util/Enumeration.html">Enumeration</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/swing/tree/DefaultMutableTreeNode.html#EMPTY_ENUMERATION">EMPTY_ENUMERATION</A></B></CODE><BR> An enumeration that is always empty.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected <A HREF="../../../javax/swing/tree/MutableTreeNode.html">MutableTreeNode</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/swing/tree/DefaultMutableTreeNode.html#parent">parent</A></B></CODE><BR> this node's parent, or null if this node has no parent</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected <A HREF="../../../java/lang/Object.html">Object</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/swing/tree/DefaultMutableTreeNode.html#userObject">userObject</A></B></CODE><BR> optional user object</TD></TR></TABLE> <!-- ======== CONSTRUCTOR SUMMARY ======== --><A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Constructor Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../../javax/swing/tree/DefaultMutableTreeNode.html#DefaultMutableTreeNode()">DefaultMutableTreeNode</A></B>()</CODE><BR> Creates a tree node that has no parent and no children, but which allows children.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../../javax/swing/tree/DefaultMutableTreeNode.html#DefaultMutableTreeNode(java.lang.Object)">DefaultMutableTreeNode</A></B>(<A HREF="../../../java/lang/Object.html">Object</A> userObject)</CODE><BR> Creates a tree node with no parent, no children, but which allows children, and initializes it with the specified user object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../../javax/swing/tree/DefaultMutableTreeNode.html#DefaultMutableTreeNode(java.lang.Object, boolean)">DefaultMutableTreeNode</A></B>(<A HREF="../../../java/lang/Object.html">Object</A> userObject, boolean allowsChildren)</CODE><BR> Creates a tree node with no parent, no children, initialized with the specified user object, and that allows children only if specified.</TD></TR></TABLE> <!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/swing/tree/DefaultMutableTreeNode.html#add(javax.swing.tree.MutableTreeNode)">add</A></B>(<A HREF="../../../javax/swing/tree/MutableTreeNode.html">MutableTreeNode</A> newChild)</CODE><BR> Removes <code>newChild</code> from its parent and makes it a child of this node by adding it to the end of this node's child array.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../../java/util/Enumeration.html">Enumeration</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/swing/tree/DefaultMutableTreeNode.html#breadthFirstEnumeration()">breadthFirstEnumeration</A></B>()</CODE><BR> Creates and returns an enumeration that traverses the subtree rooted at this node in breadth-first order.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../../java/util/Enumeration.html">Enumeration</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/swing/tree/DefaultMutableTreeNode.html#children()">children</A></B>()</CODE><BR> Creates and returns a forward-order enumeration of this node's children.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../../java/lang/Object.html">Object</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/swing/tree/DefaultMutableTreeNode.html#clone()">clone</A></B>()</CODE><BR> Overridden to make clone public.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../../java/util/Enumeration.html">Enumeration</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/swing/tree/DefaultMutableTreeNode.html#depthFirstEnumeration()">depthFirstEnumeration</A></B>()</CODE><BR> Creates and returns an enumeration that traverses the subtree rooted at
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -