Class TreeSelectionEvent

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

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected 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 EventObject

    source
    Modifier and Type
    Field
    Description
    protected Object
    The object on which the Event initially occurred.
  • Constructor Summary

    Constructors
    Constructor
    Description
    TreeSelectionEvent(Object source, TreePath[] paths, boolean[] areNew, TreePath oldLeadSelectionPath, TreePath newLeadSelectionPath)
    Represents a change in the selection of a TreeSelectionModel.
    TreeSelectionEvent(Object source, TreePath path, boolean isNew, TreePath oldLeadSelectionPath, TreePath newLeadSelectionPath)
    Represents a change in the selection of a TreeSelectionModel.
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    Returns the first path element.
    Returns the paths that have been added or removed from the selection.
    boolean
    Returns whether the path identified by getPath was added to the selection.
    boolean
    isAddedPath(int index)
    Returns whether the path at getPaths()[index] was added to the selection.
    boolean
    Returns whether the specified path was added to the selection.

    Methods declared in class EventObject

    getSource, toString
    Modifier and Type
    Method
    Description
    The object on which the Event initially occurred.
    Returns a String representation of this EventObject.

    Methods declared in class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    Modifier and Type
    Method
    Description
    protected Object
    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.
    boolean
    Compares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.
    protected void
    Deprecated, for removal: This API element is subject to removal in a future version.
    May cause performance issues, deadlocks and hangs.
    final Class<? extends Object>
    Answers the unique instance of java.lang.Class which represents the class of the receiver.
    int
    Answers an integer hash code for the receiver.
    final void
    Causes one thread which is waiting on the receiver to be made ready to run.
    final void
    Causes all threads which are waiting on the receiver to be made ready to run.
    final void
    Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated by notify or notifyAll).
    final void
    wait(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 by notify or notifyAll) or the expiration of the timeout.
    final void
    wait(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 by notify or notifyAll) or the expiration of the timeout.
  • Field Details

    • paths

      protected TreePath[] paths
      Paths this event represents.
    • areNew

      protected boolean[] areNew
      For each path identifies if that path is in fact new.
    • oldLeadSelectionPath

      protected TreePath oldLeadSelectionPath
      leadSelectionPath before the paths changed, may be null.
    • newLeadSelectionPath

      protected TreePath 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 a 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 - a boolean array indicating whether the paths in paths 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)
      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 - 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 the paths that have been added or removed from the selection.
      Returns:
      copy of the array of TreePath objects for this event.
    • getPath

      public TreePath getPath()
      Returns the first path element.
      Returns:
      the first TreePath element represented by this event
    • isAddedPath

      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:
      true if getPath was added to the selection, false otherwise
    • isAddedPath

      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 - the path to test
      Returns:
      true if path was added to the selection, false otherwise
      Throws:
      IllegalArgumentException - if path is not contained in getPaths
      See Also:
    • isAddedPath

      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 - 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 of getPaths
      Since:
      1.3
      See Also:
    • getOldLeadSelectionPath

      public TreePath getOldLeadSelectionPath()
      Returns the path that was previously the lead path.
      Returns:
      a TreePath containing the old lead selection path
    • getNewLeadSelectionPath

      public TreePath getNewLeadSelectionPath()
      Returns the current lead path.
      Returns:
      a TreePath containing the new lead selection path
    • cloneWithSource

      public Object cloneWithSource(Object newSource)
      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 the newSource provided