TreeSelectionEventpublic 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 JavaBeansTM
has been added to the java.beans package.
Please see {@link java.beans.XMLEncoder}. |
Fields Summary |
---|
protected TreePath[] | pathsPaths this event represents. | protected boolean[] | areNewFor each path identifies if that path is in fact new. | protected TreePath | oldLeadSelectionPathleadSelectionPath before the paths changed, may be null. | protected TreePath | newLeadSelectionPathleadSelectionPath after the paths changed, may be null. |
Constructors 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.
super(source);
this.paths = paths;
this.areNew = areNew;
this.oldLeadSelectionPath = oldLeadSelectionPath;
this.newLeadSelectionPath = newLeadSelectionPath;
| 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 have been either added or
removed from the selection.
super(source);
paths = new TreePath[1];
paths[0] = path;
areNew = new boolean[1];
areNew[0] = isNew;
this.oldLeadSelectionPath = oldLeadSelectionPath;
this.newLeadSelectionPath = newLeadSelectionPath;
|
Methods Summary |
---|
public java.lang.Object | cloneWithSource(java.lang.Object newSource)Returns a copy of the receiver, but with the source being newSource.
// Fix for IE bug - crashing
return new TreeSelectionEvent(newSource, paths,areNew,
oldLeadSelectionPath,
newLeadSelectionPath);
| public javax.swing.tree.TreePath | getNewLeadSelectionPath()Returns the current lead path.
return newLeadSelectionPath;
| public javax.swing.tree.TreePath | getOldLeadSelectionPath()Returns the path that was previously the lead path.
return oldLeadSelectionPath;
| public javax.swing.tree.TreePath | getPath()Returns the first path element.
return paths[0];
| public javax.swing.tree.TreePath[] | getPaths()Returns the paths that have been added or removed from the
selection.
int numPaths;
TreePath[] retPaths;
numPaths = paths.length;
retPaths = new TreePath[numPaths];
System.arraycopy(paths, 0, retPaths, 0, numPaths);
return retPaths;
| public boolean | isAddedPath()Returns true if the first path element has been added to the
selection, a return value of false means the first path has been
removed from the selection.
return areNew[0];
| public boolean | isAddedPath(javax.swing.tree.TreePath path)Returns true if the path identified by path was added to the
selection. A return value of false means the path was in the
selection but is no longer in the selection. This will raise if
path is not one of the paths identified by this event.
for(int counter = paths.length - 1; counter >= 0; counter--)
if(paths[counter].equals(path))
return areNew[counter];
throw new IllegalArgumentException("path is not a path identified by the TreeSelectionEvent");
| public boolean | isAddedPath(int index)Returns true if the path identified by index was added to
the selection. A return value of false means the path was in the
selection but is no longer in the selection. This will raise if
index < 0 || >= getPaths .length.
if (paths == null || index < 0 || index >= paths.length) {
throw new IllegalArgumentException("index is beyond range of added paths identified by TreeSelectionEvent");
}
return areNew[index];
|
|