Additional top-level class in compilation unit: PathPlaceHolder.
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 JavaBeans
has been added to the java.beans package.
Please see java..
javax.swing.JTree
| Modifier and Type | Field and Description |
|---|---|
| protected SwingPropertyChangeSupport | changeSupport
Used to messaged registered listeners. |
| private Hashtable | |
| protected int | leadIndex
Index of the lead path in selection. |
| protected TreePath | leadPath
Last path that was added. |
| protected int | leadRow
Lead row. |
| protected EventListenerList | listenerList
Event listener list. |
| protected DefaultListSelectionModel | listSelectionModel
Handles maintaining the list selection model. |
| protected transient RowMapper | rowMapper
Provides a row for a given path. |
| protected TreePath[] | selection
Paths that are currently selected. |
| public static final String | SELECTION_MODE_PROPERTY
Property name for selectionMode. |
| protected int | selectionMode
Mode for the selection, will be either SINGLE_TREE_SELECTION, CONTIGUOUS_TREE_SELECTION or DISCONTIGUOUS_TREE_SELECTION. |
| private TreePath[] | |
| private Hashtable | uniquePaths
Used to make sure the paths are unique, will contain all the paths
in |
| Access | Constructor and Description |
|---|---|
| public | DefaultTreeSelectionModel()
Creates a new instance of DefaultTreeSelectionModel that is empty, with a selection mode of DISCONTIGUOUS_TREE_SELECTION. |
| Modifier and Type | Method and Description |
|---|---|
| public synchronized void | addPropertyChangeListener(PropertyChangeListener
the PropertyChangeListener to be added listener)Implements javax. Adds a PropertyChangeListener to the listener list. |
| public void | addSelectionPath(TreePath
the new path to add to the current selection path)Implements javax. Adds path to the current selection. |
| public void | addSelectionPaths(TreePath[]
the new path to add to the current selection paths)Implements javax. Adds paths to the current selection. |
| public void | addTreeSelectionListener(TreeSelectionListener
the new listener to be added x)Implements javax. Adds x to the list of listeners that are notified each time the set of selected TreePaths changes. |
| protected boolean | Returns: whether the paths are contiguous, or this object has no RowMapperarray of paths to check paths)Returns true if the paths are contiguous, or this object has no RowMapper. |
| protected boolean | Returns: whether the particular set ofTreePaths can be addedarray of paths)TreePaths to checkUsed to test if a particular set of |
| protected boolean | Returns: whether the paths can be removed without breaking the continuity of the modelarray of paths)TreePath to checkReturns true if the paths can be removed without breaking the continuity of the model. |
| public void | clearSelection()
Implements javax. Empties the current selection. |
| public Object | |
| protected void | fireValueChanged(TreeSelectionEvent
the event that characterizes the change e)Notifies all listeners that are registered for tree selection events on this object. |
| public TreePath | getLeadSelectionPath()
Implements javax. Returns the last path that was added. |
| public int | getLeadSelectionRow()
Implements javax. Returns the lead selection index. |
| public < the listener type T extends EventListener> T[] | Returns: an array of all objects registered asFooListeners on this component,
or an empty array if no such
listeners have been addedthe type of listeners requested listenerType)Returns an array of all the objects currently registered
as |
| public int | getMaxSelectionRow()
Implements javax. Returns the largest value obtained from the RowMapper for the current set of selected TreePaths. |
| public int | getMinSelectionRow()
Implements javax. Returns the smallest value obtained from the RowMapper for the current set of selected TreePaths. |
| public PropertyChangeListener[] | Returns: all of this model'sPropertyChangeListeners
or an empty
array if no property change listeners are currently registeredReturns an array of all the property change listeners
registered on this |
| public RowMapper | getRowMapper()
Implements javax. Returns the RowMapper instance that is able to map a TreePath to a row. |
| public int | getSelectionCount()
Implements javax. Returns the number of paths that are selected. |
| public int | getSelectionMode()
Implements javax. Returns the selection mode, one of |
| public TreePath | getSelectionPath()
Implements javax. Returns the first path in the selection. |
| public TreePath[] | Returns: the selectionImplements javax. Returns the selection. |
| public int[] | Returns: the selection in terms of rowsImplements javax. Returns the selection in terms of rows. |
| public TreeSelectionListener[] | Returns: all of this model'sTreeSelectionListeners
or an empty
array if no tree selection listeners are currently registeredReturns an array of all the tree selection listeners registered on this model. |
| protected void | insureRowContinuity()
Makes sure the currently selected |
| protected void | |
| public boolean | isPathSelected(TreePath path)
Implements javax. Returns true if the path, |
| public boolean | isRowSelected(int row)
Implements javax. Returns true if the row identified by |
| public boolean | isSelectionEmpty()
Implements javax. Returns true if the selection is currently empty. |
| protected void | notifyPathChange(Vector<?>
the vector of the changed paths changedPaths, TreePath the old selection path oldLeadSelection)
Deprecated
As of JDK version 1.7
Notifies listeners of a change in path. |
| private void | |
| public synchronized void | removePropertyChangeListener(PropertyChangeListener
the PropertyChangeListener to be removed listener)Implements javax. Removes a PropertyChangeListener from the listener list. |
| public void | removeSelectionPath(TreePath
the path to remove from the selection path)Implements javax. Removes path from the selection. |
| public void | removeSelectionPaths(TreePath[]
the paths to remove from the selection paths)Implements javax. Removes paths from the selection. |
| public void | removeTreeSelectionListener(TreeSelectionListener
the listener to remove x)Implements javax. Removes x from the list of listeners that are notified each time the set of selected TreePaths changes. |
| public void | resetRowSelection()
Implements javax. Updates this object's mapping from TreePath to rows. |
| public void | setRowMapper(RowMapper newMapper)
Implements javax. Sets the RowMapper instance. |
| public void | setSelectionMode(int mode)
Implements javax. Sets the selection model, which must be one of SINGLE_TREE_SELECTION, CONTIGUOUS_TREE_SELECTION or DISCONTIGUOUS_TREE_SELECTION. |
| public void | setSelectionPath(TreePath
new path to select path)Implements javax. Sets the selection to path. |
| public void | setSelectionPaths(TreePath[]
the new selection pPaths)Implements javax. Sets the selection. |
| public String | Returns: a String representation of this objectOverrides java. Returns a string that displays and identifies this object's properties. |
| protected void | |
| private static int | |
| private void |
| changeSupport | back to summary |
|---|---|
| protected SwingPropertyChangeSupport changeSupport Used to messaged registered listeners. | |
| lastPaths | back to summary |
|---|---|
| private Hashtable<TreePath, Boolean> lastPaths | |
| leadIndex | back to summary |
|---|---|
| protected int leadIndex Index of the lead path in selection. | |
| leadPath | back to summary |
|---|---|
| protected TreePath leadPath Last path that was added. | |
| leadRow | back to summary |
|---|---|
| protected int leadRow Lead row. | |
| listenerList | back to summary |
|---|---|
| protected EventListenerList listenerList Event listener list. | |
| listSelectionModel | back to summary |
|---|---|
| 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. | |
| rowMapper | back to summary |
|---|---|
| protected transient RowMapper rowMapper Provides a row for a given path. | |
| selection | back to summary |
|---|---|
| protected TreePath[] selection Paths that are currently selected. Will be null if nothing is currently selected. | |
| SELECTION_MODE_PROPERTY | back to summary |
|---|---|
| public static final String SELECTION_MODE_PROPERTY Property name for selectionMode. | |
| selectionMode | back to summary |
|---|---|
| protected int selectionMode Mode for the selection, will be either SINGLE_TREE_SELECTION, CONTIGUOUS_TREE_SELECTION or DISCONTIGUOUS_TREE_SELECTION. | |
| tempPaths | back to summary |
|---|---|
| private TreePath[] tempPaths | |
| uniquePaths | back to summary |
|---|---|
| private Hashtable<TreePath, Boolean> uniquePaths Used to make sure the paths are unique, will contain all the paths
in | |
| DefaultTreeSelectionModel | back to summary |
|---|---|
| public DefaultTreeSelectionModel() Creates a new instance of DefaultTreeSelectionModel that is empty, with a selection mode of DISCONTIGUOUS_TREE_SELECTION. | |
| addPropertyChangeListener | back to summary |
|---|---|
| public synchronized void addPropertyChangeListener(PropertyChangeListener listener) Implements javax. Adds a PropertyChangeListener to the listener list. The listener is registered for all properties. A PropertyChangeEvent will get fired when the selection mode changes.
| |
| addSelectionPath | back to summary |
|---|---|
| public void addSelectionPath(TreePath path) Implements javax. Adds path to the current selection. If path is not currently
in the selection the TreeSelectionListeners are notified. This has
no effect if
| |
| addSelectionPaths | back to summary |
|---|---|
| public void addSelectionPaths(TreePath[] paths) Implements javax. 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 The lead path is set to the last element in If the selection mode is
| |
| addTreeSelectionListener | back to summary |
|---|---|
| public void addTreeSelectionListener(TreeSelectionListener x) Implements javax. Adds x to the list of listeners that are notified each time the set of selected TreePaths changes.
| |
| arePathsContiguous | back to summary |
|---|---|
| protected boolean arePathsContiguous(TreePath[] paths) Returns true if the paths are contiguous, or this object has no RowMapper.
| |
| canPathsBeAdded | back to summary |
|---|---|
| protected boolean canPathsBeAdded(TreePath[] paths) Used to test if a particular set of
| |
| canPathsBeRemoved | back to summary |
|---|---|
| protected boolean canPathsBeRemoved(TreePath[] paths) Returns true if the paths can be removed without breaking the continuity of the model. This is rather expensive.
| |
| clearSelection | back to summary |
|---|---|
| public void clearSelection() Implements javax. Empties the current selection. If this represents a change in the current selection, the selection listeners are notified. | |
| clone | back to summary |
|---|---|
| public Object clone() throws CloneNotSupportedException Overrides java. Returns a clone of this object with the same selection. This method does not duplicate selection listeners and property listeners.
| |
| fireValueChanged | back to summary |
|---|---|
| protected void fireValueChanged(TreeSelectionEvent e) Notifies all listeners that are registered for tree selection events on this object.
| |
| getLeadSelectionPath | back to summary |
|---|---|
| public TreePath getLeadSelectionPath() Implements javax. Returns the last path that was added. This may differ from the leadSelectionPath property maintained by the JTree. | |
| getLeadSelectionRow | back to summary |
|---|---|
| public int getLeadSelectionRow() Implements javax. Returns the lead selection index. That is the last index that was added. | |
| getListeners | back to summary |
|---|---|
| public <T extends EventListener> T[] getListeners(Class<T> listenerType) Returns an array of all the objects currently registered
as
You can specify the TreeSelectionListener[] tsls = (TreeSelectionListener[])(m.getListeners(TreeSelectionListener.class));If no such listeners exist, this method returns an empty array.
| |
| getMaxSelectionRow | back to summary |
|---|---|
| public int getMaxSelectionRow() Implements javax. 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. | |
| getMinSelectionRow | back to summary |
|---|---|
| public int getMinSelectionRow() Implements javax. 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. | |
| getPropertyChangeListeners | back to summary |
|---|---|
| public PropertyChangeListener[] getPropertyChangeListeners() Returns an array of all the property change listeners
registered on this
| |
| getRowMapper | back to summary |
|---|---|
| public RowMapper getRowMapper() Implements javax. Returns the RowMapper instance that is able to map a TreePath to a row. | |
| getSelectionCount | back to summary |
|---|---|
| public int getSelectionCount() Implements javax. Returns the number of paths that are selected. | |
| getSelectionMode | back to summary |
|---|---|
| public int getSelectionMode() Implements javax. Returns the selection mode, one of | |
| getSelectionPath | back to summary |
|---|---|
| public TreePath getSelectionPath() Implements javax. Returns the first path in the selection. This is useful if there if only one item currently selected. | |
| getSelectionPaths | back to summary |
|---|---|
| public TreePath[] getSelectionPaths() Implements javax. Returns the selection.
| |
| getSelectionRows | back to summary |
|---|---|
| public int[] getSelectionRows() Implements javax. Returns the selection in terms of rows. There is not
necessarily a one-to-one mapping between the
| |
| getTreeSelectionListeners | back to summary |
|---|---|
| public TreeSelectionListener[] getTreeSelectionListeners() Returns an array of all the tree selection listeners registered on this model.
| |
| insureRowContinuity | back to summary |
|---|---|
| protected void insureRowContinuity() Makes sure the currently selected
If the selection mode is | |
| insureUniqueness | back to summary |
|---|---|
| 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 compatibility. | |
| isPathSelected | back to summary |
|---|---|
| public boolean isPathSelected(TreePath path) Implements javax. Returns true if the path, | |
| isRowSelected | back to summary |
|---|---|
| public boolean isRowSelected(int row) Implements javax. Returns true if the row identified by | |
| isSelectionEmpty | back to summary |
|---|---|
| public boolean isSelectionEmpty() Implements javax. Returns true if the selection is currently empty. | |
| notifyPathChange | back to summary |
|---|---|
| protected void notifyPathChange(Vector<?> changedPaths, TreePath oldLeadSelection)
Deprecated As of JDK version 1.7 Notifies listeners of a change in path. changePaths should contain instances of PathPlaceHolder.
| |
| readObject | back to summary |
|---|---|
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException
| |
| removePropertyChangeListener | back to summary |
|---|---|
| public synchronized void removePropertyChangeListener(PropertyChangeListener listener) Implements javax. Removes a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.
| |
| removeSelectionPath | back to summary |
|---|---|
| public void removeSelectionPath(TreePath path) Implements javax. Removes path from the selection. If path is in the selection
The TreeSelectionListeners are notified. This has no effect if
| |
| removeSelectionPaths | back to summary |
|---|---|
| public void removeSelectionPaths(TreePath[] paths) Implements javax. 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
| |
| removeTreeSelectionListener | back to summary |
|---|---|
| public void removeTreeSelectionListener(TreeSelectionListener x) Implements javax. Removes x from the list of listeners that are notified each time the set of selected TreePaths changes.
| |
| resetRowSelection | back to summary |
|---|---|
| public void resetRowSelection() Implements javax. 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 | |
| setRowMapper | back to summary |
|---|---|
| public void setRowMapper(RowMapper newMapper) Implements javax. Sets the RowMapper instance. This instance is used to determine the row for a particular TreePath. | |
| setSelectionMode | back to summary |
|---|---|
| public void setSelectionMode(int mode) Implements javax. 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,
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 | |
| setSelectionPath | back to summary |
|---|---|
| public void setSelectionPath(TreePath path) Implements javax. Sets the selection to path. If this represents a change, then
the TreeSelectionListeners are notified. If
| |
| setSelectionPaths | back to summary |
|---|---|
| public void setSelectionPaths(TreePath[] pPaths) Implements javax. Sets the selection. Whether the supplied paths are taken as the
new selection depends upon the selection mode. If the supplied
array is
All
If this represents a change, all registered The lead path is set to the last unique path.
The paths returned from
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a string that displays and identifies this object's properties.
| |
| updateLeadIndex | back to summary |
|---|---|
| protected void updateLeadIndex() Updates the leadIndex instance variable. | |
| validateSelectionMode | back to summary |
|---|---|
| private static int validateSelectionMode(int mode) | |
| writeObject | back to summary |
|---|---|
private void writeObject(ObjectOutputStream s) throws IOException
| |