java.lang.Object
java.util.EventObject
javax.swing.event.TreeSelectionEvent
- All Implemented Interfaces:
Serializable
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 XMLEncoder
.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean[]
For each path identifies if that path is in fact new.protected TreePath
leadSelectionPath after the paths changed, may be null.protected TreePath
leadSelectionPath before the paths changed, may be null.protected TreePath[]
Paths this event represents.Fields declared in class java.util.EventObject
source
-
Constructor Summary
ConstructorDescriptionTreeSelectionEvent
(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 Summary
Modifier and TypeMethodDescriptioncloneWithSource
(Object newSource) Returns a copy of the receiver, but with the source being newSource.Returns the current lead path.Returns the path that was previously the lead path.getPath()
Returns the first path element.TreePath[]
getPaths()
Returns the paths that have been added or removed from the selection.boolean
Returns whether the path identified bygetPath
was added to the selection.boolean
isAddedPath
(int index) Returns whether the path atgetPaths()[index]
was added to the selection.boolean
isAddedPath
(TreePath path) Returns whether the specified path was added to the selection.Methods declared in class java.util.EventObject
getSource, toString
-
Field Details
-
paths
Paths this event represents. -
areNew
protected boolean[] areNewFor each path identifies if that path is in fact new. -
oldLeadSelectionPath
leadSelectionPath before the paths changed, may be null. -
newLeadSelectionPath
leadSelectionPath after the paths changed, may be null.
-
-
Constructor Details
-
TreeSelectionEvent
public TreeSelectionEvent(Object source, TreePath[] paths, boolean[] areNew, TreePath oldLeadSelectionPath, TreePath newLeadSelectionPath) Represents a change in the selection of aTreeSelectionModel
.paths
identifies the paths that have been either added or removed from the selection.- Parameters:
source
- source of eventpaths
- the paths that have changed in the selectionareNew
- aboolean
array indicating whether the paths inpaths
are new to the selectionoldLeadSelectionPath
- the previous lead selection pathnewLeadSelectionPath
- the new lead selection path
-
TreeSelectionEvent
public TreeSelectionEvent(Object source, TreePath path, boolean isNew, TreePath oldLeadSelectionPath, TreePath newLeadSelectionPath) Represents a change in the selection of aTreeSelectionModel
.path
identifies the path that has been either added or removed from the selection.- Parameters:
source
- source of eventpath
- the path that has changed in the selectionisNew
- whether or not the path is new to the selection, false means path was removed from the selection.oldLeadSelectionPath
- the previous lead selection pathnewLeadSelectionPath
- the new lead selection path
-
-
Method Details
-
getPaths
Returns the paths that have been added or removed from the selection.- Returns:
- copy of the array of
TreePath
obects for this event.
-
getPath
Returns the first path element.- Returns:
- the first
TreePath
element represented by this event
-
isAddedPath
public boolean isAddedPath()Returns whether the path identified bygetPath
was added to the selection. A return value oftrue
indicates the path identified bygetPath
was added to the selection. A return value offalse
indicatesgetPath
was selected, but is no longer selected.- Returns:
true
ifgetPath
was added to the selection,false
otherwise
-
isAddedPath
Returns whether the specified path was added to the selection. A return value oftrue
indicates the path identified bypath
was added to the selection. A return value offalse
indicatespath
is 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:
true
ifpath
was added to the selection,false
otherwise- Throws:
IllegalArgumentException
- ifpath
is not contained ingetPaths
- See Also:
-
isAddedPath
public boolean isAddedPath(int index) Returns whether the path atgetPaths()[index]
was added to the selection. A return value oftrue
indicates the path was added to the selection. A return value offalse
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
Returns the path that was previously the lead path.- Returns:
- a
TreePath
containing the old lead selection path
-
getNewLeadSelectionPath
Returns the current lead path.- Returns:
- a
TreePath
containing the new lead selection path
-
cloneWithSource
Returns a copy of the receiver, but with the source being newSource.- Parameters:
newSource
- source of event- Returns:
- an
Object
which is a copy of this event with the source being thenewSource
provided
-