📄 defaulttreemodel.html
字号:
DefaultTreeModel</H3><PRE>public <B>DefaultTreeModel</B>(<A HREF="../../../javax/swing/tree/TreeNode.html">TreeNode</A> root)</PRE><DL><DD>Creates a tree in which any node can have children.<DD><DL><DT><B>Parameters:</B><DD><CODE>root</CODE> - a TreeNode object that is the root of the tree<DT><B>See Also: </B><DD><A HREF="../../../javax/swing/tree/DefaultTreeModel.html#DefaultTreeModel(javax.swing.tree.TreeNode, boolean)"><CODE>DefaultTreeModel(TreeNode, boolean)</CODE></A></DL></DD></DL><HR><A NAME="DefaultTreeModel(javax.swing.tree.TreeNode, boolean)"><!-- --></A><H3>DefaultTreeModel</H3><PRE>public <B>DefaultTreeModel</B>(<A HREF="../../../javax/swing/tree/TreeNode.html">TreeNode</A> root, boolean asksAllowsChildren)</PRE><DL><DD>Creates a tree specifying whether any node can have children, or whether only certain nodes can have children.<DD><DL><DT><B>Parameters:</B><DD><CODE>root</CODE> - a TreeNode object that is the root of the tree<DD><CODE>askAllowsChildren</CODE> - a boolean, false if any node can have children, true if each node is asked to see if it can have children<DT><B>See Also: </B><DD><A HREF="../../../javax/swing/tree/DefaultTreeModel.html#asksAllowsChildren"><CODE>asksAllowsChildren</CODE></A></DL></DD></DL><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Method Detail</B></FONT></TD></TR></TABLE><A NAME="setAsksAllowsChildren(boolean)"><!-- --></A><H3>setAsksAllowsChildren</H3><PRE>public void <B>setAsksAllowsChildren</B>(boolean newValue)</PRE><DL><DD>Sets whether or not to test leafness by asking getAllowsChildren() or isLeaf() to the TreeNodes. If newvalue is true, getAllowsChildren() is messaged, otherwise isLeaf() is messaged.<DD><DL></DL></DD></DL><HR><A NAME="asksAllowsChildren()"><!-- --></A><H3>asksAllowsChildren</H3><PRE>public boolean <B>asksAllowsChildren</B>()</PRE><DL><DD>Tells how leaf nodes are determined.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>true if only nodes which do not allow children are leaf nodes, false if nodes which have no children (even if allowed) are leaf nodes<DT><B>See Also: </B><DD><A HREF="../../../javax/swing/tree/DefaultTreeModel.html#asksAllowsChildren"><CODE>asksAllowsChildren</CODE></A></DL></DD></DL><HR><A NAME="setRoot(javax.swing.tree.TreeNode)"><!-- --></A><H3>setRoot</H3><PRE>public void <B>setRoot</B>(<A HREF="../../../javax/swing/tree/TreeNode.html">TreeNode</A> root)</PRE><DL><DD>Sets the root to <code>root</code>. This will throw an IllegalArgumentException if <code>root</code> is null.<DD><DL></DL></DD></DL><HR><A NAME="getRoot()"><!-- --></A><H3>getRoot</H3><PRE>public <A HREF="../../../java/lang/Object.html">Object</A> <B>getRoot</B>()</PRE><DL><DD>Returns the root of the tree. Returns null only if the tree has no nodes.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../../javax/swing/tree/TreeModel.html#getRoot()">getRoot</A></CODE> in interface <CODE><A HREF="../../../javax/swing/tree/TreeModel.html">TreeModel</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>the root of the tree</DL></DD></DL><HR><A NAME="getIndexOfChild(java.lang.Object, java.lang.Object)"><!-- --></A><H3>getIndexOfChild</H3><PRE>public int <B>getIndexOfChild</B>(<A HREF="../../../java/lang/Object.html">Object</A> parent, <A HREF="../../../java/lang/Object.html">Object</A> child)</PRE><DL><DD>Returns the index of child in parent.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../../javax/swing/tree/TreeModel.html#getIndexOfChild(java.lang.Object, java.lang.Object)">getIndexOfChild</A></CODE> in interface <CODE><A HREF="../../../javax/swing/tree/TreeModel.html">TreeModel</A></CODE></DL></DD></DL><HR><A NAME="getChild(java.lang.Object, int)"><!-- --></A><H3>getChild</H3><PRE>public <A HREF="../../../java/lang/Object.html">Object</A> <B>getChild</B>(<A HREF="../../../java/lang/Object.html">Object</A> parent, int index)</PRE><DL><DD>Returns the child of <I>parent</I> at index <I>index</I> in the parent's child array. <I>parent</I> must be a node previously obtained from this data source. This should not return null if <i>index</i> is a valid index for <i>parent</i> (that is <i>index</i> >= 0 && <i>index</i> < getChildCount(<i>parent</i>)).<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../../javax/swing/tree/TreeModel.html#getChild(java.lang.Object, int)">getChild</A></CODE> in interface <CODE><A HREF="../../../javax/swing/tree/TreeModel.html">TreeModel</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>parent</CODE> - a node in the tree, obtained from this data source<DT><B>Returns:</B><DD>the child of <I>parent</I> at index <I>index</I></DL></DD></DL><HR><A NAME="getChildCount(java.lang.Object)"><!-- --></A><H3>getChildCount</H3><PRE>public int <B>getChildCount</B>(<A HREF="../../../java/lang/Object.html">Object</A> parent)</PRE><DL><DD>Returns the number of children of <I>parent</I>. Returns 0 if the node is a leaf or if it has no children. <I>parent</I> must be a node previously obtained from this data source.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../../javax/swing/tree/TreeModel.html#getChildCount(java.lang.Object)">getChildCount</A></CODE> in interface <CODE><A HREF="../../../javax/swing/tree/TreeModel.html">TreeModel</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>parent</CODE> - a node in the tree, obtained from this data source<DT><B>Returns:</B><DD>the number of children of the node <I>parent</I></DL></DD></DL><HR><A NAME="isLeaf(java.lang.Object)"><!-- --></A><H3>isLeaf</H3><PRE>public boolean <B>isLeaf</B>(<A HREF="../../../java/lang/Object.html">Object</A> node)</PRE><DL><DD>Returns whether the specified node is a leaf node. The way the test is performed depends on the <code>askAllowsChildren</code> setting.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../../javax/swing/tree/TreeModel.html#isLeaf(java.lang.Object)">isLeaf</A></CODE> in interface <CODE><A HREF="../../../javax/swing/tree/TreeModel.html">TreeModel</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>node</CODE> - the node to check<DT><B>Returns:</B><DD>true if the node is a leaf node<DT><B>See Also: </B><DD><A HREF="../../../javax/swing/tree/DefaultTreeModel.html#asksAllowsChildren"><CODE>asksAllowsChildren</CODE></A>, <A HREF="../../../javax/swing/tree/TreeModel.html#isLeaf(java.lang.Object)"><CODE>TreeModel.isLeaf(java.lang.Object)</CODE></A></DL></DD></DL><HR><A NAME="reload()"><!-- --></A><H3>reload</H3><PRE>public void <B>reload</B>()</PRE><DL><DD>Invoke this method if you've modified the TreeNodes upon which this model depends. The model will notify all of its listeners that the model has changed.<DD><DL></DL></DD></DL><HR><A NAME="valueForPathChanged(javax.swing.tree.TreePath, java.lang.Object)"><!-- --></A><H3>valueForPathChanged</H3><PRE>public void <B>valueForPathChanged</B>(<A HREF="../../../javax/swing/tree/TreePath.html">TreePath</A> path, <A HREF="../../../java/lang/Object.html">Object</A> newValue)</PRE><DL><DD>This sets the user object of the TreeNode identified by path and posts a node changed. If you use custom user objects in the TreeModel you're going to need to subclass this and set the user object of the changed node to something meaningful.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../../javax/swing/tree/TreeModel.html#valueForPathChanged(javax.swing.tree.TreePath, java.lang.Object)">valueForPathChanged</A></CODE> in interface <CODE><A HREF="../../../javax/swing/tree/TreeModel.html">TreeModel</A></CODE></DL></DD><DD>Following copied from interface: <CODE>javax.swing.tree.TreeModel</CODE></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>path</CODE> - path to the node that the user has altered.<DD><CODE>newValue</CODE> - the new value from the TreeCellEditor.</DL></DD></DL><HR><A NAME="insertNodeInto(javax.swing.tree.MutableTreeNode, javax.swing.tree.MutableTreeNode, int)"><!-- --></A><H3>insertNodeInto</H3><PRE>public void <B>insertNodeInto</B>(<A HREF="../../../javax/swing/tree/MutableTreeNode.html">MutableTreeNode</A> newChild, <A HREF="../../../javax/swing/tree/MutableTreeNode.html">MutableTreeNode</A> parent, int index)</PRE><DL><DD>Invoked this to insert newChild at location index in parents children. This will then message nodesWereInserted to create the appropriate event. This is the preferred way to add children as it will create the appropriate event.<DD><DL></DL></DD></DL><HR><A NAME="removeNodeFromParent(javax.swing.tree.MutableTreeNode)"><!-- --></A><H3>removeNodeFromParent</H3><PRE>public void <B>removeNodeFromParent</B>(<A HREF="../../../javax/swing/tree/MutableTreeNode.html">MutableTreeNode</A> node)</PRE><DL><DD>Message this to remove node from its parent. This will message nodesWereRemoved to create the appropriate event. This is the preferred way to remove a node as it handles the event creation for you.<DD><DL></DL></DD></DL><HR><A NAME="nodeChanged(javax.swing.tree.TreeNode)"><!-- --></A><H3>nodeChanged</H3><PRE>public void <B>nodeChanged</B>(<A HREF="../../../javax/swing/tree/TreeNode.html">TreeNode</A> node)</PRE><DL><DD>Invoke this method after you've changed how node is to be represented in the tree.<DD><DL></DL></DD></DL><HR><A NAME="reload(javax.swing.tree.TreeNode)"><!-- --></A><H3>reload</H3><PRE>public void <B>reload</B>(<A HREF="../../../javax/swing/tree/TreeNode.html">TreeNode</A> node)</PRE><DL><DD>Invoke this method if you've modified the TreeNodes upon which this model depends. The model will notify all of its listeners that the model has changed below the node <code>node</code> (PENDING).<DD><DL></DL></DD></DL><HR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -