📄 treemodelevent.html
字号:
protected <A HREF="../../../java/lang/Object.html">Object</A>[] <B>children</B></PRE><DL><DD>Children that have been removed.</DL><!-- ========= CONSTRUCTOR DETAIL ======== --><A NAME="constructor_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Constructor Detail</B></FONT></TD></TR></TABLE><A NAME="TreeModelEvent(java.lang.Object, java.lang.Object[], int[], java.lang.Object[])"><!-- --></A><H3>TreeModelEvent</H3><PRE>public <B>TreeModelEvent</B>(<A HREF="../../../java/lang/Object.html">Object</A> source, <A HREF="../../../java/lang/Object.html">Object</A>[] path, int[] childIndices, <A HREF="../../../java/lang/Object.html">Object</A>[] children)</PRE><DL><DD>Used to create an event when nodes have been changed, inserted, or removed, identifying the path to the parent of the modified items as an array of Objects. All of the modified objects are siblings which are direct descendents (not grandchildren) of the specified parent. The positions at which the inserts, deletes, or changes occured are specified by an array of <code>int</code>. The indexes in that array must be in order, from lowest to highest. <p> For changes, the indexes in the model correspond exactly to the indexes of items currently displayed in the UI. As a result, it is not really critical if the indexes are not in their exact order. But after multiple inserts or deletes, the items currently in the UI no longer correspond to the items in the model. It is therefore critical to specify the indexes properly for inserts and deletes. <p> For inserts, the indexes represent the <i>final</i> state of the tree, after the inserts have occurred. Since the indexes must be specified in order, the most natural processing methodology is to do the inserts starting at the lowest index and working towards the highest. Accumulate a Vector of <code>Integer</code> objects that specify the insert-locations as you go, then convert the Vector to an array of <code>int</code> to create the event. When the postition-index equals zero, the node is inserted at the beginning of the list. When the position index equals the size of the list, the node is "inserted" at (appended to) the end of the list. <p> For deletes, the indexes represent the <i>initial</i> state of the tree, before the deletes have occurred. Since the indexes must be specified in order, the most natural processing methodology is to use a delete-counter. Start by initializing the counter to zero and start work through the list from lowest to higest. Every time you do a delete, add the current value of the delete-counter to the index-position where the delete occurred, and append the result to a Vector of delete-locations, using <code>addElement()</code>. Then increment the delete-counter. The index positions stored in the Vector therefore reflect the effects of all previous deletes, so they represent each object's position in the initial tree. (You could also start at the highest index and working back towards the lowest, accumulating a Vector of delete-locations as you go using the <code>insertElementAt(Integer, 0)</code>.) However you produce the Vector of initial-positions, you then need to convert the Vector of <code>Integer</code> objects to an array of <code>int</code> to create the event. <p> <b>Notes:</b><ul> <li>Like the <code>insertNodeInto</code> method in the <code>DefaultTreeModel</code> class, <code>insertElementAt</code> appends to the <code>Vector</code> when the index matches the size of the vector. So you can use <code>insertElementAt(Integer, 0)</code> even when the vector is empty. <ul>To create a node changed event for the root node, specify the parent as null and the "child" index as zero. </ul><DD><DL><DT><B>Parameters:</B><DD><CODE>source</CODE> - the Object responsible for generating the event (typically the creator of the event object passes <code>this</code> for its value)<DD><CODE>path</CODE> - an array of Object identifying the path to the parent of the modified item(s), where the first element of the array is the Object stored at the root node and the last element is the Object stored at the parent node<DD><CODE>childIndices</CODE> - an array of <code>int</code> that specifies the index values of the removed items. The indices must be in sorted order, from lowest to highest<DD><CODE>children</CODE> - an array of Object containing the inserted, removed, or changed objects<DT><B>See Also: </B><DD><A HREF="../../../javax/swing/tree/TreePath.html"><CODE>TreePath</CODE></A></DL></DD></DL><HR><A NAME="TreeModelEvent(java.lang.Object, javax.swing.tree.TreePath, int[], java.lang.Object[])"><!-- --></A><H3>TreeModelEvent</H3><PRE>public <B>TreeModelEvent</B>(<A HREF="../../../java/lang/Object.html">Object</A> source, <A HREF="../../../javax/swing/tree/TreePath.html">TreePath</A> path, int[] childIndices, <A HREF="../../../java/lang/Object.html">Object</A>[] children)</PRE><DL><DD>Used to create an event when nodes have been changed, inserted, or removed, identifying the path to the parent of the modified items as a TreePath object. For more information on how to specify the indexes and objects, see <code>TreeModelEvent(Object,Object[],int[],Object[])</code>.<DD><DL><DT><B>Parameters:</B><DD><CODE>source</CODE> - the Object responsible for generating the event (typically the creator of the event object passes <code>this</code> for its value)<DD><CODE>path</CODE> - a TreePath object that identifies the path to the parent of the modified item(s)<DD><CODE>childIndices</CODE> - an array of <code>int</code> that specifies the index values of the modified items<DD><CODE>children</CODE> - an array of Object containing the inserted, removed, or changed objects<DT><B>See Also: </B><DD><A HREF="../../../javax/swing/event/TreeModelEvent.html#TreeModelEvent(java.lang.Object, java.lang.Object[], int[], java.lang.Object[])"><CODE>TreeModelEvent(Object,Object[],int[],Object[])</CODE></A></DL></DD></DL><HR><A NAME="TreeModelEvent(java.lang.Object, java.lang.Object[])"><!-- --></A><H3>TreeModelEvent</H3><PRE>public <B>TreeModelEvent</B>(<A HREF="../../../java/lang/Object.html">Object</A> source, <A HREF="../../../java/lang/Object.html">Object</A>[] path)</PRE><DL><DD>Used to create an event when the node structure has changed in some way, identifying the path to the root of a modified subtree as an array of Objects. A structure change event might involve nodes swapping position, for example, or it might encapsulate multiple inserts and deletes in the subtree stemming from the node, where the changes may have taken place at different levels of the subtree. <blockquote> <b>Note:</b><br> JTree collapses all nodes under the specified node, so that only its immediate children are visible. </blockquote><DD><DL><DT><B>Parameters:</B><DD><CODE>source</CODE> - the Object responsible for generating the event (typically the creator of the event object passes <code>this</code> for its value)<DD><CODE>path</CODE> - an array of Object identifying the path to the root of the modified subtree, where the first element of the array is the object stored at the root node and the last element is the object stored at the changed node<DT><B>See Also: </B><DD><A HREF="../../../javax/swing/tree/TreePath.html"><CODE>TreePath</CODE></A></DL></DD></DL><HR><A NAME="TreeModelEvent(java.lang.Object, javax.swing.tree.TreePath)"><!-- --></A><H3>TreeModelEvent</H3><PRE>public <B>TreeModelEvent</B>(<A HREF="../../../java/lang/Object.html">Object</A> source, <A HREF="../../../javax/swing/tree/TreePath.html">TreePath</A> path)</PRE><DL><DD>Used to create an event when the node structure has changed in some way, identifying the path to the root of the modified subtree as a TreePath object. For more information on this event specification, see <code>TreeModelEvent(Object,Object[])</code>.<DD><DL><DT><B>Parameters:</B><DD><CODE>source</CODE> - the Object responsible for generating the event (typically the creator of the event object passes <code>this</code> for its value)<DD><CODE>path</CODE> - a TreePath object that identifies the path to the change. In the DefaultTreeModel, this object contains an array of user-data objects, but a subclass of TreePath could use some totally different mechanism -- for example, a node ID number<DT><B>See Also: </B><DD><A HREF="../../../javax/swing/event/TreeModelEvent.html#TreeModelEvent(java.lang.Object, java.lang.Object[])"><CODE>TreeModelEvent(Object,Object[])</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="getTreePath()"><!-- --></A><H3>getTreePath</H3><PRE>public <A HREF="../../../javax/swing/tree/TreePath.html">TreePath</A> <B>getTreePath</B>()</PRE><DL><DD>For all events, except treeStructureChanged, returns the parent of the changed nodes. For treeStructureChanged events, returns the ancestor of the structure that has changed. This and <code>getChildIndices</code> are used to get a list of the effected nodes. <p> The one exception to this is a treeNodesChanged event that is to identify the root, in which case this will return the root and <code>getChildIndices</code> will return null.<DD><DL><DT><B>Returns:</B><DD>the TreePath used in identifying the changed nodes.<DT><B>See Also: </B><DD><A HREF="../../../javax/swing/tree/TreePath.html#getLastPathComponent()"><CODE>TreePath.getLastPathComponent()</CODE></A></DL></DD></DL><HR><A NAME="getPath()"><!-- --></A><H3>getPath</H3><PRE>public <A HREF="../../../java/lang/Object.html">Object</A>[] <B>getPath</B>()</PRE><DL><DD>Convenience method to get the array of objects from the TreePath instance that this event wraps.<DD><DL><DT><B>Returns:</B><DD>an array of Objects, where the first Object is the one stored at the root and the last object is the one stored at the node identified by the path</DL></DD></DL><HR><A NAME="getChildren()"><!-- --></A><H3>getChildren</H3><PRE>public <A HREF="../../../java/lang/Object.html">Object</A>[] <B>getChildren</B>()</PRE><DL><DD>Returns the objects that are children of the node identified by <code>getPath</code> at the locations specified by <code>getChildIndices</code>. If this is a removal event the returned objects are no longer children of the parent node.<DD><DL><DT><B>Returns:</B><DD>an array of Object containing the children specified by the event<DT><B>See Also: </B><DD><A HREF="../../../javax/swing/event/TreeModelEvent.html#getPath()"><CODE>getPath()</CODE></A>, <A HREF="../../../javax/swing/event/TreeModelEvent.html#getChildIndices()"><CODE>getChildIndices()</CODE></A></DL></DD></DL><HR><A NAME="getChildIndices()"><!-- --></A><H3>getChildIndices</H3><PRE>public int[] <B>getChildIndices</B>()</PRE><DL><DD>Returns the values of the child indexes. If this is a removal event the indexes point to locations in the initial list where items were removed. If it is an insert, the indices point to locations in the final list where the items were added. For node changes, the indices point to the locations of the modified nodes.<DD><DL><DT><B>Returns:</B><DD>an array of <code>int</code> containing index locations for the children specified by the event</DL></DD></DL><HR><A NAME="toString()"><!-- --></A><H3>toString</H3><PRE>public <A HREF="../../../java/lang/String.html">String</A> <B>toString</B>()</PRE><DL><DD>Returns a string that displays and identifies this object's properties.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../../java/util/EventObject.html#toString()">toString</A></CODE> in class <CODE><A HREF="../../../java/util/EventObject.html">EventObject</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>a String representation of this object</DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_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/TreeModelEvent.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/event/TreeExpansionEvent.html"><B>PREV CLASS</B></A> <A HREF="../../../javax/swing/event/TreeSelectionEvent.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="TreeModelEvent.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><font size="-1"><a href="http://java.sun.com/cgi-bin/bugreport.cgi">Submit a bug or feature</a><br>For further API reference and developer documentation, see <a href="http://java.sun.com/products/jdk/1.3/devdocs-vs-specs.html">Java 2 SDK SE Developer Documentation</a>. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. <p>Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.<br>Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road<br>Palo Alto, California, 94303, U.S.A. All Rights Reserved.</font></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -