APIdia Launch Partner
Top Description Fields Constructors Methods
javax.swing.event

public Class TreeSelectionEvent

extends EventObject
Class Inheritance
Annotations
@SuppressWarnings:serial
Imports
java.util.EventObject, javax.swing.tree.TreePath

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.beans package. Please see java.beans.XMLEncoder.

Author
Scott Violet
See Also
TreeSelectionListener, javax.swing.tree.TreeSelectionModel

Field Summary

Modifier and TypeField and Description
protected boolean[]
areNew

For each path identifies if that path is in fact new.

protected TreePath
newLeadSelectionPath

leadSelectionPath after the paths changed, may be null.

protected TreePath
oldLeadSelectionPath

leadSelectionPath before the paths changed, may be null.

protected TreePath[]
paths

Paths this event represents.

Inherited from java.util.EventObject:
source

Constructor Summary

AccessConstructor and Description
public
TreeSelectionEvent(Object
source of event
source
,
TreePath[]
the paths that have changed in the selection
paths
,
boolean[]
a boolean array indicating whether the paths in paths are new to the selection
areNew
,
TreePath
the previous lead selection path
oldLeadSelectionPath
,
TreePath
the new lead selection path
newLeadSelectionPath
)

Represents a change in the selection of a TreeSelectionModel.

public
TreeSelectionEvent(Object
source of event
source
,
TreePath
the path that has changed in the selection
path
,
boolean
whether or not the path is new to the selection, false means path was removed from the selection.
isNew
,
TreePath
the previous lead selection path
oldLeadSelectionPath
,
TreePath
the new lead selection path
newLeadSelectionPath
)

Represents a change in the selection of a TreeSelectionModel.

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

an Object which is a copy of this event with the source being the newSource provided
cloneWithSource
(Object
source of event
newSource
)

Returns a copy of the receiver, but with the source being newSource.

public TreePath

Returns:

a TreePath containing the new lead selection path
getNewLeadSelectionPath
()

Returns the current lead path.

public TreePath

Returns:

a TreePath containing the old lead selection path
getOldLeadSelectionPath
()

Returns the path that was previously the lead path.

public TreePath

Returns:

the first TreePath element represented by this event
getPath
()

Returns the first path element.

public TreePath[]

Returns:

copy of the array of TreePath objects for this event.
getPaths
()

Returns the paths that have been added or removed from the selection.

public boolean

Returns:

true if getPath was added to the selection, false otherwise
isAddedPath
()

Returns whether the path identified by getPath was added to the selection.

public boolean

Returns:

true if path was added to the selection, false otherwise
isAddedPath
(TreePath
the path to test
path
)

Returns whether the specified path was added to the selection.

public boolean

Returns:

true if the path was added to the selection, false otherwise
isAddedPath
(int
the index of the path to test
index
)

Returns whether the path at getPaths()[index] was added to the selection.

Inherited from java.util.EventObject:
getSourcetoString

Field Detail

areNewback to summary
protected boolean[] areNew

For each path identifies if that path is in fact new.

newLeadSelectionPathback to summary
protected TreePath newLeadSelectionPath

leadSelectionPath after the paths changed, may be null.

oldLeadSelectionPathback to summary
protected TreePath oldLeadSelectionPath

leadSelectionPath before the paths changed, may be null.

pathsback to summary
protected TreePath[] paths

Paths this event represents.

Constructor Detail

TreeSelectionEventback to summary
public TreeSelectionEvent(Object source, TreePath[] paths, boolean[] areNew, TreePath oldLeadSelectionPath, TreePath newLeadSelectionPath)

Represents a change in the selection of a TreeSelectionModel. paths identifies the paths that have been either added or removed from the selection.

Parameters
source:Object

source of event

paths:TreePath[]

the paths that have changed in the selection

areNew:boolean[]

a boolean array indicating whether the paths in paths are new to the selection

oldLeadSelectionPath:TreePath

the previous lead selection path

newLeadSelectionPath:TreePath

the new lead selection path

TreeSelectionEventback to summary
public TreeSelectionEvent(Object source, TreePath path, boolean isNew, TreePath oldLeadSelectionPath, TreePath newLeadSelectionPath)

Represents a change in the selection of a TreeSelectionModel. path identifies the path that has been either added or removed from the selection.

Parameters
source:Object

source of event

path:TreePath

the path that has changed in the selection

isNew:boolean

whether or not the path is new to the selection, false means path was removed from the selection.

oldLeadSelectionPath:TreePath

the previous lead selection path

newLeadSelectionPath:TreePath

the new lead selection path

Method Detail

cloneWithSourceback to summary
public Object cloneWithSource(Object newSource)

Returns a copy of the receiver, but with the source being newSource.

Parameters
newSource:Object

source of event

Returns:Object

an Object which is a copy of this event with the source being the newSource provided

getNewLeadSelectionPathback to summary
public TreePath getNewLeadSelectionPath()

Returns the current lead path.

Returns:TreePath

a TreePath containing the new lead selection path

getOldLeadSelectionPathback to summary
public TreePath getOldLeadSelectionPath()

Returns the path that was previously the lead path.

Returns:TreePath

a TreePath containing the old lead selection path

getPathback to summary
public TreePath getPath()

Returns the first path element.

Returns:TreePath

the first TreePath element represented by this event

getPathsback to summary
public TreePath[] getPaths()

Returns the paths that have been added or removed from the selection.

Returns:TreePath[]

copy of the array of TreePath objects for this event.

isAddedPathback to summary
public boolean isAddedPath()

Returns whether the path identified by getPath was added to the selection. A return value of true indicates the path identified by getPath was added to the selection. A return value of false indicates getPath was selected, but is no longer selected.

Returns:boolean

true if getPath was added to the selection, false otherwise

isAddedPathback to summary
public boolean isAddedPath(TreePath path)

Returns whether the specified path was added to the selection. A return value of true indicates the path identified by path was added to the selection. A return value of false indicates path is no longer selected. This method is only valid for the paths returned from getPaths(); invoking with a path not included in getPaths() throws an IllegalArgumentException.

Parameters
path:TreePath

the path to test

Returns:boolean

true if path was added to the selection, false otherwise

Exceptions
IllegalArgumentException:
if path is not contained in getPaths
See Also
getPaths
isAddedPathback to summary
public boolean isAddedPath(int index)

Returns whether the path at getPaths()[index] was added to the selection. A return value of true indicates the path was added to the selection. A return value of false indicates the path is no longer selected.

Parameters
index:int

the index of the path to test

Returns:boolean

true if the path was added to the selection, false otherwise

Exceptions
IllegalArgumentException:
if index is outside the range of getPaths
Since
1.3
See Also
getPaths