Java Doc for TreeModelEvent.java in  » 6.0-JDK-Core » swing » javax » swing » event » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » swing » javax.swing.event 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.util.EventObject
      javax.swing.event.TreeModelEvent

TreeModelEvent
public class TreeModelEvent extends EventObject (Code)
Encapsulates information describing changes to a tree model, and used to notify tree model listeners of the change. For more information and examples see How to Write a Tree Model Listener, a section in The Java Tutorial.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder .
version:
   1.40 05/05/07
author:
   Rob Davis
author:
   Ray Ryan
author:
   Scott Violet



Field Summary
protected  int[]childIndices
     Indices identifying the position of where the children were.
protected  Object[]children
     Children that have been removed.
protected  TreePathpath
     Path to the parent of the nodes that have changed.

Constructor 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.
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.
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.
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.

Method Summary
public  int[]getChildIndices()
     Returns the values of the child indexes.
public  Object[]getChildren()
     Returns the objects that are children of the node identified by getPath at the locations specified by getChildIndices.
public  Object[]getPath()
     Convenience method to get the array of objects from the TreePath instance that this event wraps.
public  TreePathgetTreePath()
     For all events, except treeStructureChanged, returns the parent of the changed nodes. For treeStructureChanged events, returns the ancestor of the structure that has changed.
public  StringtoString()
     Returns a string that displays and identifies this object's properties.

Field Detail
childIndices
protected int[] childIndices(Code)
Indices identifying the position of where the children were.



children
protected Object[] children(Code)
Children that have been removed.



path
protected TreePath path(Code)
Path to the parent of the nodes that have changed.




Constructor Detail
TreeModelEvent
public TreeModelEvent(Object source, Object[] path, int[] childIndices, Object[] children)(Code)
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 int. The indexes in that array must be in order, from lowest to highest.

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 Integer objects that specify the insert-locations as you go, then convert the Vector to an array of int 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.

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 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 addElement(). 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 insertElementAt(Integer, 0).) However you produce the Vector of initial-positions, you then need to convert the Vector of Integer objects to an array of int to create the event.

Notes:

  • Like the insertNodeInto method in the DefaultTreeModel class, insertElementAt appends to the Vector when the index matches the size of the vector. So you can use insertElementAt(Integer, 0) even when the vector is empty.
      To create a node changed event for the root node, specify the parent and the child indices as null.

    Parameters:
      source - the Object responsible for generating the event (typicallythe creator of the event object passes thisfor its value)
    Parameters:
      path - an array of Object identifying the path to theparent of the modified item(s), where the first elementof the array is the Object stored at the root node andthe last element is the Object stored at the parent node
    Parameters:
      childIndices - an array of int that specifies theindex values of the removed items. The indices must bein sorted order, from lowest to highest
    Parameters:
      children - an array of Object containing the inserted, removed, orchanged objects
    See Also:   TreePath



TreeModelEvent
public TreeModelEvent(Object source, TreePath path, int[] childIndices, Object[] children)(Code)
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(Object,Object[],int[],Object[]).
Parameters:
  source - the Object responsible for generating the event (typicallythe creator of the event object passes thisfor its value)
Parameters:
  path - a TreePath object that identifies the path to theparent of the modified item(s)
Parameters:
  childIndices - an array of int that specifies theindex values of the modified items
Parameters:
  children - an array of Object containing the inserted, removed, orchanged objects
See Also:   TreeModelEvent.TreeModelEvent(Object,Object[],int[],Object[])



TreeModelEvent
public TreeModelEvent(Object source, Object[] path)(Code)
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.

Parameters:
  source - the Object responsible for generating the event (typicallythe creator of the event object passes thisfor its value)
Parameters:
  path - an array of Object identifying the path to the root of themodified subtree, where the first element of the array isthe object stored at the root node and the last elementis the object stored at the changed node
See Also:   TreePath



TreeModelEvent
public TreeModelEvent(Object source, TreePath path)(Code)
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 TreeModelEvent(Object,Object[]).
Parameters:
  source - the Object responsible for generating the event (typicallythe creator of the event object passes thisfor its value)
Parameters:
  path - a TreePath object that identifies the path to thechange. In the DefaultTreeModel,this object contains an array of user-data objects,but a subclass of TreePath could use some totallydifferent mechanism -- for example, a node ID number
See Also:   TreeModelEvent.TreeModelEvent(Object,Object[])




Method Detail
getChildIndices
public int[] getChildIndices()(Code)
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. an array of int containing index locations forthe children specified by the event



getChildren
public Object[] getChildren()(Code)
Returns the objects that are children of the node identified by getPath at the locations specified by getChildIndices. If this is a removal event the returned objects are no longer children of the parent node. an array of Object containing the children specified bythe event
See Also:   TreeModelEvent.getPath
See Also:   TreeModelEvent.getChildIndices



getPath
public Object[] getPath()(Code)
Convenience method to get the array of objects from the TreePath instance that this event wraps. an array of Objects, where the first Object is the onestored at the root and the last object is the onestored at the node identified by the path



getTreePath
public TreePath getTreePath()(Code)
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 getChildIndices are used to get a list of the effected nodes.

The one exception to this is a treeNodesChanged event that is to identify the root, in which case this will return the root and getChildIndices will return null. the TreePath used in identifying the changed nodes.
See Also:   TreePath.getLastPathComponent




toString
public String toString()(Code)
Returns a string that displays and identifies this object's properties. a String representation of this object



Fields inherited from java.util.EventObject
protected transient Object source(Code)(Java Doc)

Methods inherited from java.util.EventObject
public Object getSource()(Code)(Java Doc)
public String toString()(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.