Class TreeSelectionEvent
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
FieldsModifier and TypeFieldDescriptionprotected boolean[]For each path identifies if that path is in fact new.protected TreePathleadSelectionPath after the paths changed, may be null.protected TreePathleadSelectionPath before the paths changed, may be null.protected TreePath[]Paths this event represents.Fields declared in class EventObject
source -
Constructor Summary
ConstructorsConstructorDescriptionTreeSelectionEvent(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.booleanReturns 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 EventObject
getSource, toStringMethods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
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.pathsidentifies 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- abooleanarray indicating whether the paths inpathsare 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.pathidentifies 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
TreePathobjects for this event.
-
getPath
Returns the first path element.- Returns:
- the first
TreePathelement represented by this event
-
isAddedPath
public 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:
trueifgetPathwas added to the selection,falseotherwise
-
isAddedPath
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:
trueifpathwas added to the selection,falseotherwise- Throws:
IllegalArgumentException- ifpathis 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 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 ofgetPaths- Since:
- 1.3
- See Also:
-
getOldLeadSelectionPath
Returns the path that was previously the lead path.- Returns:
- a
TreePathcontaining the old lead selection path
-
getNewLeadSelectionPath
Returns the current lead path.- Returns:
- a
TreePathcontaining the new lead selection path
-
cloneWithSource
-