Class TreeSelectionEvent
- All Implemented Interfaces:
Serializable
public class TreeSelectionEvent extends EventObject
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 XMLEncoder
.
- See Also:
Field Summary
Modifier and Type | Field | 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. |
Fields declared in class java.util.EventObject
source
Constructor Summary
Constructor | Description |
---|---|
TreeSelectionEvent |
Represents a change in the selection of a TreeSelectionModel . |
TreeSelectionEvent |
Represents a change in the selection of a TreeSelectionModel . |
Method Summary
Modifier and Type | Method | Description |
---|---|---|
Object |
cloneWithSource |
Returns a copy of the receiver, but with the source being newSource. |
TreePath |
getNewLeadSelectionPath() |
Returns the current lead path. |
TreePath |
getOldLeadSelectionPath() |
Returns the path that was previously the lead path. |
TreePath |
getPath() |
Returns the first path element. |
TreePath[] |
getPaths() |
Returns the paths that have been added or removed from the selection. |
boolean |
isAddedPath() |
Returns whether the path identified by getPath was added to the selection. |
boolean |
isAddedPath |
Returns whether the path at getPaths()[index] was added to the selection. |
boolean |
isAddedPath |
Returns whether the specified path was added to the selection. |
Methods declared in class java.util.EventObject
getSource, toString
Field Details
paths
protected TreePath[] paths
areNew
protected boolean[] areNew
oldLeadSelectionPath
protected TreePath oldLeadSelectionPath
newLeadSelectionPath
protected TreePath newLeadSelectionPath
Constructor Details
TreeSelectionEvent
public TreeSelectionEvent(Object source, TreePath[] paths, boolean[] areNew, TreePath oldLeadSelectionPath, TreePath newLeadSelectionPath)
TreeSelectionModel
. paths
identifies 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
- aboolean
array indicating whether the paths inpaths
are new to the selection -
oldLeadSelectionPath
- the previous lead selection path -
newLeadSelectionPath
- the new lead selection path
TreeSelectionEvent
public TreeSelectionEvent(Object source, TreePath path, boolean isNew, TreePath oldLeadSelectionPath, TreePath newLeadSelectionPath)
TreeSelectionModel
. path
identifies 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 Details
getPaths
public TreePath[] getPaths()
- Returns:
- copy of the array of
TreePath
obects for this event.
getPath
public TreePath getPath()
- Returns:
- the first
TreePath
element represented by this event
isAddedPath
public boolean isAddedPath()
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:
-
true
ifgetPath
was added to the selection,false
otherwise
isAddedPath
public boolean isAddedPath(TreePath path)
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
- the path to test - Returns:
-
true
ifpath
was added to the selection,false
otherwise - Throws:
-
IllegalArgumentException
- ifpath
is not contained ingetPaths
- See Also:
isAddedPath
public boolean isAddedPath(int index)
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
- the index of the path to test - Returns:
-
true
if the path was added to the selection,false
otherwise - Throws:
-
IllegalArgumentException
- if index is outside the range ofgetPaths
- Since:
- 1.3
- See Also:
getOldLeadSelectionPath
public TreePath getOldLeadSelectionPath()
- Returns:
- a
TreePath
containing the old lead selection path
getNewLeadSelectionPath
public TreePath getNewLeadSelectionPath()
- Returns:
- a
TreePath
containing the new lead selection path
cloneWithSource
public Object cloneWithSource(Object newSource)
- Parameters:
-
newSource
- source of event - Returns:
- an
Object
which is a copy of this event with the source being thenewSource
provided
© 1993, 2021, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/javax/swing/event/TreeSelectionEvent.html