- java.lang.Object
- 
- java.util.EventObject
- 
- javax.swing.event.TreeSelectionEvent
 
 
- 
- All Implemented Interfaces:
- Serializable
 
 public class TreeSelectionEvent extends EventObject An event that characterizes a change in the current selection. The change is based on any number of paths. TreeSelectionListeners will generally query the source of the event for the new selected status of each potentially changed row.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.beanspackage. Please seeXMLEncoder.- See Also:
- TreeSelectionListener,- TreeSelectionModel, Serialized Form
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected boolean[]areNewFor each path identifies if that path is in fact new.protected TreePathnewLeadSelectionPathleadSelectionPath after the paths changed, may be null.protected TreePatholdLeadSelectionPathleadSelectionPath before the paths changed, may be null.protected TreePath[]pathsPaths this event represents.- 
Fields declared in class java.util.EventObjectsource
 
- 
 - 
Constructor SummaryConstructors Constructor Description TreeSelectionEvent(Object source, TreePath[] paths, boolean[] areNew, TreePath oldLeadSelectionPath, TreePath newLeadSelectionPath)Represents a change in the selection of aTreeSelectionModel.TreeSelectionEvent(Object source, TreePath path, boolean isNew, TreePath oldLeadSelectionPath, TreePath newLeadSelectionPath)Represents a change in the selection of aTreeSelectionModel.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectcloneWithSource(Object newSource)Returns a copy of the receiver, but with the source being newSource.TreePathgetNewLeadSelectionPath()Returns the current lead path.TreePathgetOldLeadSelectionPath()Returns the path that was previously the lead path.TreePathgetPath()Returns the first path element.TreePath[]getPaths()Returns the paths that have been added or removed from the selection.booleanisAddedPath()Returns whether the path identified bygetPathwas added to the selection.booleanisAddedPath(int index)Returns whether the path atgetPaths()[index]was added to the selection.booleanisAddedPath(TreePath path)Returns whether the specified path was added to the selection.- 
Methods declared in class java.util.EventObjectgetSource, toString
 
- 
 
- 
- 
- 
Field Detail- 
pathsprotected TreePath[] paths Paths this event represents.
 - 
areNewprotected boolean[] areNew For each path identifies if that path is in fact new.
 - 
oldLeadSelectionPathprotected TreePath oldLeadSelectionPath leadSelectionPath before the paths changed, may be null.
 - 
newLeadSelectionPathprotected TreePath newLeadSelectionPath leadSelectionPath after the paths changed, may be null.
 
- 
 - 
Constructor Detail- 
TreeSelectionEventpublic TreeSelectionEvent(Object source, TreePath[] paths, boolean[] areNew, TreePath oldLeadSelectionPath, TreePath newLeadSelectionPath) Represents a change in the selection of aTreeSelectionModel.pathsidentifies the paths that have been either added or removed from the selection.- Parameters:
- source- source of event
- paths- the paths that have changed in the selection
- areNew- a- booleanarray indicating whether the paths in- pathsare new to the selection
- oldLeadSelectionPath- the previous lead selection path
- newLeadSelectionPath- the new lead selection path
 
 - 
TreeSelectionEventpublic TreeSelectionEvent(Object source, TreePath path, boolean isNew, TreePath oldLeadSelectionPath, TreePath newLeadSelectionPath) Represents a change in the selection of aTreeSelectionModel.pathidentifies the path that has been either added or removed from the selection.- Parameters:
- source- source of event
- path- the path that has changed in the selection
- isNew- whether or not the path is new to the selection, false means path was removed from the selection.
- oldLeadSelectionPath- the previous lead selection path
- newLeadSelectionPath- the new lead selection path
 
 
- 
 - 
Method Detail- 
getPathspublic TreePath[] getPaths() Returns the paths that have been added or removed from the selection.- Returns:
- copy of the array of TreePathobects for this event.
 
 - 
getPathpublic TreePath getPath() Returns the first path element.- Returns:
- the first TreePathelement represented by this event
 
 - 
isAddedPathpublic boolean isAddedPath() Returns whether the path identified bygetPathwas added to the selection. A return value oftrueindicates the path identified bygetPathwas added to the selection. A return value offalseindicatesgetPathwas selected, but is no longer selected.- Returns:
- trueif- getPathwas added to the selection,- falseotherwise
 
 - 
isAddedPathpublic boolean isAddedPath(TreePath path) Returns whether the specified path was added to the selection. A return value oftrueindicates the path identified bypathwas added to the selection. A return value offalseindicatespathis no longer selected. This method is only valid for the paths returned fromgetPaths(); invoking with a path not included ingetPaths()throws anIllegalArgumentException.- Parameters:
- path- the path to test
- Returns:
- trueif- pathwas added to the selection,- falseotherwise
- Throws:
- IllegalArgumentException- if- pathis not contained in- getPaths
- See Also:
- getPaths()
 
 - 
isAddedPathpublic boolean isAddedPath(int index) Returns whether the path atgetPaths()[index]was added to the selection. A return value oftrueindicates the path was added to the selection. A return value offalseindicates the path is no longer selected.- Parameters:
- index- the index of the path to test
- Returns:
- trueif the path was added to the selection,- falseotherwise
- Throws:
- IllegalArgumentException- if index is outside the range of- getPaths
- Since:
- 1.3
- See Also:
- getPaths()
 
 - 
getOldLeadSelectionPathpublic TreePath getOldLeadSelectionPath() Returns the path that was previously the lead path.- Returns:
- a TreePathcontaining the old lead selection path
 
 - 
getNewLeadSelectionPathpublic TreePath getNewLeadSelectionPath() Returns the current lead path.- Returns:
- a TreePathcontaining the new lead selection path
 
 
- 
 
-