| public class javax.swing.tree DefaultTreeSelectionModel
|
Java SE 6 |
resetRowSelection is called from any of the methods that update
the selected paths. If you subclass any of these methods to
filter what is allowed to be selected, be sure and message
resetRowSelection if you do not message super.
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 java.beans.XMLEncoder.
| version | 1.51 11/17/05 |
| See also | javax.swing.JTree |
| Fields | |
|---|---|
| final public static String | SELECTION_MODE_PROPERTY Property name for selectionMode. |
| protected SwingPropertyChangeSupport | changeSupport Used to messaged registered listeners. |
| protected TreePath[] | selection Paths that are currently selected. Will be null if nothing is currently selected. |
| protected EventListenerList | listenerList Event listener list. |
| protected RowMapper | rowMapper Provides a row for a given path. |
| protected DefaultListSelectionModel | listSelectionModel Handles maintaining the list selection model. The RowMapper is used to map from a TreePath to a row, and the value is then placed here. |
| protected int | selectionMode Mode for the selection, will be either SINGLE_TREE_SELECTION, CONTIGUOUS_TREE_SELECTION or DISCONTIGUOUS_TREE_SELECTION. |
| protected TreePath | leadPath Last path that was added. |
| protected int | leadIndex Index of the lead path in selection. |
| protected int | leadRow Lead row. |
| Constructors | |
|---|---|
| public | DefaultTreeSelectionModel() Creates a new instance of DefaultTreeSelectionModel that is empty, with a selection mode of DISCONTIGUOUS_TREE_SELECTION. |
| Methods | |||
|---|---|---|---|
| public void | addPropertyChangeListener(PropertyChangeListener listener) Details
Adds a PropertyChangeListener to the listener list.
The listener is registered for all properties.
A PropertyChangeEvent will get fired when the selection mode changes.
| ||
| public void | addSelectionPath(TreePath path) Details
Adds path to the current selection. If path is not currently
in the selection the TreeSelectionListeners are notified. This has
no effect if path is null.
| ||
| public void | addSelectionPaths(TreePath[] paths) Details
Adds paths to the current selection. If any of the paths in
paths are not currently in the selection the TreeSelectionListeners
are notified. This has
no effect if paths is null.
The lead path is set to the last element in If the selection mode is
| ||
| public void | addTreeSelectionListener(TreeSelectionListener x) Details
Adds x to the list of listeners that are notified each time the
set of selected TreePaths changes.
| ||
| protected boolean | arePathsContiguous(TreePath[] paths) Returns true if the paths are contiguous, or this object has no RowMapper. | ||
| protected boolean | canPathsBeAdded(TreePath[] paths) Used to test if a particular set of TreePaths can
be added. This will return true if paths is null (or
empty), or this object has no RowMapper, or nothing is currently selected,
or the selection mode is DISCONTIGUOUS_TREE_SELECTION, or
adding the paths to the current selection still results in a
contiguous set of TreePaths.
| ||
| protected boolean | canPathsBeRemoved(TreePath[] paths) Returns true if the paths can be removed without breaking the continuity of the model. This is rather expensive. | ||
| public void | clearSelection() Empties the current selection. If this represents a change in the current selection, the selection listeners are notified. | ||
| public Object | clone() throws CloneNotSupportedException Details
Returns a clone of this object with the same selection.
This method does not duplicate
selection listeners and property listeners.
| ||
| protected void | fireValueChanged(TreeSelectionEvent e) Details
Notifies all listeners that are registered for
tree selection events on this object.
| ||
| protected void | insureRowContinuity() Makes sure the currently selected TreePaths are valid
for the current selection mode.
If the selection mode is CONTIGUOUS_TREE_SELECTION
and a RowMapper exists, this will make sure all
the rows are contiguous, that is, when sorted all the rows are
in order with no gaps.
If the selection isn't contiguous, the selection is
reset to contain the first set, when sorted, of contiguous rows.
If the selection mode is | ||
| protected void | insureUniqueness() This method is obsolete and its implementation is now a noop. It's still called by setSelectionPaths and addSelectionPaths, but only for backwards compatability. | ||
| protected void | notifyPathChange(Vector changedPaths, TreePath oldLeadSelection) Notifies listeners of a change in path. changePaths should contain instances of PathPlaceHolder. | ||
| public void | removePropertyChangeListener(PropertyChangeListener listener) Details
Removes a PropertyChangeListener from the listener list.
This removes a PropertyChangeListener that was registered
for all properties.
| ||
| public void | removeSelectionPath(TreePath path) Details
Removes path from the selection. If path is in the selection
The TreeSelectionListeners are notified. This has no effect if
path is null.
| ||
| public void | removeSelectionPaths(TreePath[] paths) Details
Removes paths from the selection. If any of the paths in paths
are in the selection the TreeSelectionListeners are notified.
This has no effect if paths is null.
| ||
| public void | removeTreeSelectionListener(TreeSelectionListener x) Details
Removes x from the list of listeners that are notified each time
the set of selected TreePaths changes.
| ||
| public void | resetRowSelection() Updates this object's mapping from TreePath to rows. This should be invoked when the mapping from TreePaths to integers has changed (for example, a node has been expanded). You do not normally have to call this, JTree and its associated Listeners will invoke this for you. If you are implementing your own View class, then you will have to invoke this. This will invoke | ||
| public String | toString() Details
Returns a string that displays and identifies this
object's properties.
| ||
| protected void | updateLeadIndex() Updates the leadIndex instance variable. | ||
| Properties | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| public TreePath | getLeadSelectionPath() Returns the last path that was added. This may differ from the leadSelectionPath property maintained by the JTree. | ||||||||||
| public int | getLeadSelectionRow() Returns the lead selection index. That is the last index that was added. | ||||||||||
| public EventListener[]<T> | getListeners(Class listenerType) Details
Returns an array of all the objects currently registered
as FooListeners
upon this model.
FooListeners are registered using the
addFooListener method.
You can specify the TreeSelectionListener[] tsls = (TreeSelectionListener[])(m.getListeners(TreeSelectionListener.class));If no such listeners exist, this method returns an empty array.
| ||||||||||
| public int | getMaxSelectionRow() Returns the largest value obtained from the RowMapper for the current set of selected TreePaths. If nothing is selected, or there is no RowMapper, this will return -1. | ||||||||||
| public int | getMinSelectionRow() Returns the smallest value obtained from the RowMapper for the current set of selected TreePaths. If nothing is selected, or there is no RowMapper, this will return -1. | ||||||||||
| public boolean | isPathSelected(TreePath path) Returns true if the path, path,
is in the current selection.
| ||||||||||
| public PropertyChangeListener[] | getPropertyChangeListeners() Details
Returns an array of all the property change listeners
registered on this DefaultTreeSelectionModel.
| ||||||||||
| public void | setRowMapper(RowMapper newMapper) Sets the RowMapper instance. This instance is used to determine the row for a particular TreePath. | ||||||||||
| public RowMapper | getRowMapper() Returns the RowMapper instance that is able to map a TreePath to a row. | ||||||||||
| public boolean | isRowSelected(int row) Returns true if the row identified by row is selected.
| ||||||||||
| public int | getSelectionCount() Returns the number of paths that are selected. | ||||||||||
| public boolean | isSelectionEmpty() Returns true if the selection is currently empty. | ||||||||||
| public void | setSelectionMode(int mode) Sets the selection model, which must be one of SINGLE_TREE_SELECTION, CONTIGUOUS_TREE_SELECTION or DISCONTIGUOUS_TREE_SELECTION. If mode is not one of the defined value, DISCONTIGUOUS_TREE_SELECTION is assumed.
This may change the selection if the current selection is not valid
for the new mode. For example, if three TreePaths are
selected when the mode is changed to
Setting the mode to something other than the defined types will
result in the mode becoming | ||||||||||
| public int | getSelectionMode() Returns the selection mode, one of SINGLE_TREE_SELECTION,
DISCONTIGUOUS_TREE_SELECTION or
CONTIGUOUS_TREE_SELECTION.
| ||||||||||
| public void | setSelectionPath(TreePath path) Details
Sets the selection to path. If this represents a change, then
the TreeSelectionListeners are notified. If path is
null, this has the same effect as invoking clearSelection.
| ||||||||||
| public TreePath | getSelectionPath() Returns the first path in the selection. This is useful if there if only one item currently selected. | ||||||||||
| public void | setSelectionPaths(TreePath[] pPaths) Details
Sets the selection to the paths in paths. If this represents a
change the TreeSelectionListeners are notified. Potentially
paths will be held by this object; in other words don't change
any of the objects in the array once passed in.
If The lead path is set to the last path in If the selection mode is
| ||||||||||
| public TreePath[] | getSelectionPaths() Returns the paths in the selection. This will return null (or an empty array) if nothing is currently selected. | ||||||||||
| public int[] | getSelectionRows() Returns all of the currently selected rows. This will return null (or an empty array) if there are no selected TreePaths or a RowMapper has not been set. This may return an array of length less that than of the selected TreePaths if some of the rows are not visible (that is the RowMapper returned -1 for the row corresponding to the TreePath). | ||||||||||
| public TreeSelectionListener[] | getTreeSelectionListeners() Details
Returns an array of all the tree selection listeners
registered on this model.
| ||||||||||
| About DocWeb · Bundles · Export · Export All | Top 10 · Statistics · Login |
| About Sun · Contact · Privacy · Terms of Use · Trademarks | Java SE 6 · Copyright © 1994-2009 Sun Microsystems, Inc.All rights reserved. Use is subject to license terms |
![]() |
![]() |
|