📄 defaultmutabletreenode.html
字号:
to this node's child array at index <code>childIndex</code>. <code>newChild</code> must not be null and must not be an ancestor of this node.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../../javax/swing/tree/MutableTreeNode.html#insert(javax.swing.tree.MutableTreeNode, int)">insert</A></CODE> in interface <CODE><A HREF="../../../javax/swing/tree/MutableTreeNode.html">MutableTreeNode</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>newChild</CODE> - the MutableTreeNode to insert under this node<DD><CODE>childIndex</CODE> - the index in this node's child array where this node is to be inserted<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/ArrayIndexOutOfBoundsException.html">ArrayIndexOutOfBoundsException</A></CODE> - if <code>childIndex</code> is out of bounds<DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if <code>newChild</code> is null or is an ancestor of this node<DD><CODE><A HREF="../../../java/lang/IllegalStateException.html">IllegalStateException</A></CODE> - if this node does not allow children<DT><B>See Also: </B><DD><A HREF="../../../javax/swing/tree/DefaultMutableTreeNode.html#isNodeDescendant(javax.swing.tree.DefaultMutableTreeNode)"><CODE>isNodeDescendant(javax.swing.tree.DefaultMutableTreeNode)</CODE></A></DL></DD></DL><HR><A NAME="remove(int)"><!-- --></A><H3>remove</H3><PRE>public void <B>remove</B>(int childIndex)</PRE><DL><DD>Removes the child at the specified index from this node's children and sets that node's parent to null. The child node to remove must be a <code>MutableTreeNode</code>.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../../javax/swing/tree/MutableTreeNode.html#remove(int)">remove</A></CODE> in interface <CODE><A HREF="../../../javax/swing/tree/MutableTreeNode.html">MutableTreeNode</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>childIndex</CODE> - the index in this node's child array of the child to remove<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/ArrayIndexOutOfBoundsException.html">ArrayIndexOutOfBoundsException</A></CODE> - if <code>childIndex</code> is out of bounds</DL></DD></DL><HR><A NAME="setParent(javax.swing.tree.MutableTreeNode)"><!-- --></A><H3>setParent</H3><PRE>public void <B>setParent</B>(<A HREF="../../../javax/swing/tree/MutableTreeNode.html">MutableTreeNode</A> newParent)</PRE><DL><DD>Sets this node's parent to <code>newParent</code> but does not change the parent's child array. This method is called from <code>insert()</code> and <code>remove()</code> to reassign a child's parent, it should not be messaged from anywhere else.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../../javax/swing/tree/MutableTreeNode.html#setParent(javax.swing.tree.MutableTreeNode)">setParent</A></CODE> in interface <CODE><A HREF="../../../javax/swing/tree/MutableTreeNode.html">MutableTreeNode</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>newParent</CODE> - this node's new parent</DL></DD></DL><HR><A NAME="getParent()"><!-- --></A><H3>getParent</H3><PRE>public <A HREF="../../../javax/swing/tree/TreeNode.html">TreeNode</A> <B>getParent</B>()</PRE><DL><DD>Returns this node's parent or null if this node has no parent.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../../javax/swing/tree/TreeNode.html#getParent()">getParent</A></CODE> in interface <CODE><A HREF="../../../javax/swing/tree/TreeNode.html">TreeNode</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>this node's parent TreeNode, or null if this node has no parent</DL></DD></DL><HR><A NAME="getChildAt(int)"><!-- --></A><H3>getChildAt</H3><PRE>public <A HREF="../../../javax/swing/tree/TreeNode.html">TreeNode</A> <B>getChildAt</B>(int index)</PRE><DL><DD>Returns the child at the specified index in this node's child array.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../../javax/swing/tree/TreeNode.html#getChildAt(int)">getChildAt</A></CODE> in interface <CODE><A HREF="../../../javax/swing/tree/TreeNode.html">TreeNode</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>index</CODE> - an index into this node's child array<DT><B>Returns:</B><DD>the TreeNode in this node's child array at the specified index<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/ArrayIndexOutOfBoundsException.html">ArrayIndexOutOfBoundsException</A></CODE> - if <code>index</code> is out of bounds</DL></DD></DL><HR><A NAME="getChildCount()"><!-- --></A><H3>getChildCount</H3><PRE>public int <B>getChildCount</B>()</PRE><DL><DD>Returns the number of children of this node.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../../javax/swing/tree/TreeNode.html#getChildCount()">getChildCount</A></CODE> in interface <CODE><A HREF="../../../javax/swing/tree/TreeNode.html">TreeNode</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>an int giving the number of children of this node</DL></DD></DL><HR><A NAME="getIndex(javax.swing.tree.TreeNode)"><!-- --></A><H3>getIndex</H3><PRE>public int <B>getIndex</B>(<A HREF="../../../javax/swing/tree/TreeNode.html">TreeNode</A> aChild)</PRE><DL><DD>Returns the index of the specified child in this node's child array. If the specified node is not a child of this node, returns <code>-1</code>. This method performs a linear search and is O(n) where n is the number of children.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../../javax/swing/tree/TreeNode.html#getIndex(javax.swing.tree.TreeNode)">getIndex</A></CODE> in interface <CODE><A HREF="../../../javax/swing/tree/TreeNode.html">TreeNode</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>aChild</CODE> - the TreeNode to search for among this node's children<DT><B>Returns:</B><DD>an int giving the index of the node in this node's child array, or <code>-1</code> if the specified node is a not a child of this node<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if <code>aChild</code> is null</DL></DD></DL><HR><A NAME="children()"><!-- --></A><H3>children</H3><PRE>public <A HREF="../../../java/util/Enumeration.html">Enumeration</A> <B>children</B>()</PRE><DL><DD>Creates and returns a forward-order enumeration of this node's children. Modifying this node's child array invalidates any child enumerations created before the modification.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../../javax/swing/tree/TreeNode.html#children()">children</A></CODE> in interface <CODE><A HREF="../../../javax/swing/tree/TreeNode.html">TreeNode</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>an Enumeration of this node's children</DL></DD></DL><HR><A NAME="setAllowsChildren(boolean)"><!-- --></A><H3>setAllowsChildren</H3><PRE>public void <B>setAllowsChildren</B>(boolean allows)</PRE><DL><DD>Determines whether or not this node is allowed to have children. If <code>allows</code> is false, all of this node's children are removed. <p> Note: By default, a node allows children.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>allows</CODE> - true if this node is allowed to have children</DL></DD></DL><HR><A NAME="getAllowsChildren()"><!-- --></A><H3>getAllowsChildren</H3><PRE>public boolean <B>getAllowsChildren</B>()</PRE><DL><DD>Returns true if this node is allowed to have children.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../../javax/swing/tree/TreeNode.html#getAllowsChildren()">getAllowsChildren</A></CODE> in interface <CODE><A HREF="../../../javax/swing/tree/TreeNode.html">TreeNode</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>true if this node allows children, else false</DL></DD></DL><HR><A NAME="setUserObject(java.lang.Object)"><!-- --></A><H3>setUserObject</H3><PRE>public void <B>setUserObject</B>(<A HREF="../../../java/lang/Object.html">Object</A> userObject)</PRE><DL><DD>Sets the user object for this node to <code>userObject</code>.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../../javax/swing/tree/MutableTreeNode.html#setUserObject(java.lang.Object)">setUserObject</A></CODE> in interface <CODE><A HREF="../../../javax/swing/tree/MutableTreeNode.html">MutableTreeNode</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>userObject</CODE> - the Object that constitutes this node's user-specified data<DT><B>See Also: </B><DD><A HREF="../../../javax/swing/tree/DefaultMutableTreeNode.html#getUserObject()"><CODE>getUserObject()</CODE></A>, <A HREF="../../../javax/swing/tree/DefaultMutableTreeNode.html#toString()"><CODE>toString()</CODE></A></DL></DD></DL><HR><A NAME="getUserObject()"><!-- --></A><H3>getUserObject</H3><PRE>public <A HREF="../../../java/lang/Object.html">Object</A> <B>getUserObject</B>()</PRE><DL><DD>Returns this node's user object.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the Object stored at this node by the user<DT><B>See Also: </B><DD><A HREF="../../../javax/swing/tree/DefaultMutableTreeNode.html#setUserObject(java.lang.Object)"><CODE>setUserObject(java.lang.Object)</CODE></A>, <A HREF="../../../javax/swing/tree/DefaultMutableTreeNode.html#toString()"><CODE>toString()</CODE></A></DL></DD></DL><HR><A NAME="removeFromParent()"><!-- --></A><H3>removeFromParent</H3><PRE>public void <B>removeFromParent</B>()</PRE><DL><DD>Removes the subtree rooted at this node from the tree, giving this node a null parent. Does nothing if this node is the root of its tree.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../../javax/swing/tree/MutableTreeNode.html#removeFromParent()">removeFromParent</A></CODE> in interface <CODE><A HREF="../../../javax/swing/tree/MutableTreeNode.html">MutableTreeNode</A></CODE></DL></DD></DL><HR><A NAME="remove(javax.swing.tree.MutableTreeNode)"><!-- --></A><H3>remove</H3><PRE>public void <B>remove</B>(<A HREF="../../../javax/swing/tree/MutableTreeNode.html">MutableTreeNode</A> aChild)</PRE><DL><DD>Removes <code>aChild</code> from this node's child array, giving it a null parent.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../../javax/swing/tree/MutableTreeNode.html#remove(javax.swing.tree.MutableTreeNode)">remove</A></CODE> in interface <CODE><A HREF="../../../javax/swing/tree/MutableTreeNode.html">MutableTreeNode</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>aChild</CODE> - a child of this node to remove<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if <code>aChild</code> is null or is not a child of this node</DL></DD></DL><HR><A NAME="removeAllChildren()"><!-- --></A><H3>removeAllChildren</H3><PRE>public void <B>removeAllChildren</B>()</PRE><DL><DD>Removes all of this node's children, setting their parents to null. If this node has no children, this method does nothing.<DD><DL></DL></DD></DL><HR><A NAME="add(javax.swing.tree.MutableTreeNode)"><!-- --></A><H3>add</H3><PRE>public void <B>add</B>(<A HREF="../../../javax/swing/tree/MutableTreeNode.html">MutableTreeNode</A> newChild)</PRE><DL><DD>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.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>newChild</CODE> - node to add as a child of this node<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if <code>newChild</code> is null<DD><CODE><A HREF="../../../java/lang/IllegalStateException.html">IllegalStateException</A></CODE> - if this node does not allow children<DT><B>See Also: </B><DD><A HREF="../../../javax/swing/tree/DefaultMutableTreeNode.html#insert(javax.swing.tree.MutableTreeNode, int)"><CODE>insert(javax.swing.tree.MutableTreeNode, int)</CODE></A></DL></DD></DL><HR><A NAME="isNodeAncestor(javax.swing.tree.TreeNode)"><!-- --></A><H3>isNodeAncestor</H3><PRE>public boolean <B>isNodeAncestor</B>(<A HREF="../../../javax/swing/tree/TreeNode.html">TreeNode</A> anotherNode)</PRE><DL><DD>Returns true if <code>anotherNode</code> is an ancestor of this node -- if it is this node, this node's parent, or an ancestor of this node's parent. (Note that a node is considered an ancestor of itself.) If <code>anotherNode</code> is null, this method returns false. This operation is at worst O(h) where h is the distance from the root to this node.<DD><DL></DL>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -