Warning
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. As of 1.4, support for long term storage
of all JavaBeans
has been added to the java.beans package.
Please see java..
| Modifier and Type | Field and Description |
|---|---|
| protected int[] | childIndices
Indices identifying the position of where the children were. |
| protected Object[] | children
Children that have been removed. |
| protected TreePath | path
Path to the parent of the nodes that have changed. |
| Access | Constructor and Description |
|---|---|
| public | TreeModelEvent(Object
the Object responsible for generating the event (typically
the creator of the event object passes source, Object[] this
for its value)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 path, int[] an array of childIndices, Object[] int that specifies the
index values of the removed items. The indices must be
in sorted order, from lowest to highestan array of Object containing the inserted, removed, or
changed objects children)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. |
| public | TreeModelEvent(Object
the Object responsible for generating the event (typically
the creator of the event object passes source, TreePath this
for its value)a TreePath object that identifies the path to the
parent of the modified item(s) path, int[] an array of childIndices, Object[] int that specifies the
index values of the modified itemsan array of Object containing the inserted, removed, or
changed objects children)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. |
| public | TreeModelEvent(Object
the Object responsible for generating the event (typically
the creator of the event object passes source, Object[] this
for its value)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 path)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. |
| public | TreeModelEvent(Object
the Object responsible for generating the event (typically
the creator of the event object passes source, TreePath this
for its value)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 path)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. |
| Modifier and Type | Method and Description |
|---|---|
| public int[] | Returns: an array ofint containing index locations for
the children specified by the eventReturns the values of the child indexes. |
| public Object[] | Returns: an array of Object containing the children specified by the eventReturns the objects that are children of the node identified by
|
| public Object[] | Returns: 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 pathConvenience method to get the array of objects from the TreePath instance that this event wraps. |
| public TreePath | Returns: the TreePath used in identifying the changed nodes.For all events, except treeStructureChanged, returns the parent of the changed nodes. |
| public String | Returns: a String representation of this objectOverrides java. Returns a string that displays and identifies this object's properties. |
| childIndices | back to summary |
|---|---|
| protected int[] childIndices Indices identifying the position of where the children were. | |
| children | back to summary |
|---|---|
| protected Object[] children Children that have been removed. | |
| path | back to summary |
|---|---|
| protected TreePath path Path to the parent of the nodes that have changed. | |
| TreeModelEvent | back to summary |
|---|---|
| public TreeModelEvent(Object source, Object[] path, int[] childIndices, Object[] children) 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 occurred are
specified by an array of 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.
For inserts, the indexes represent the final 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
For deletes, the indexes represent the initial 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 highest. 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
Notes:
| |
| TreeModelEvent | back to summary |
|---|---|
| public TreeModelEvent(Object source, TreePath path, int[] childIndices, Object[] children) 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
| |
| TreeModelEvent | back to summary |
|---|---|
| public TreeModelEvent(Object source, Object[] path) 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. Note JTree collapses all nodes under the specified node, so that only its immediate children are visible.
| |
| TreeModelEvent | back to summary |
|---|---|
| public TreeModelEvent(Object source, TreePath path) 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
| |
| getChildIndices | back to summary |
|---|---|
| public int[] getChildIndices() 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.
| |
| getChildren | back to summary |
|---|---|
| public Object[] getChildren() Returns the objects that are children of the node identified by
| |
| getPath | back to summary |
|---|---|
| public Object[] getPath() Convenience method to get the array of objects from the TreePath instance that this event wraps.
| |
| getTreePath | back to summary |
|---|---|
| public TreePath getTreePath() 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
The one exception to this is a treeNodesChanged event that is to
identify the root, in which case this will return the root
and
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a string that displays and identifies this object's properties.
| |