All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.java.swing.JTreeSelectionModel

java.lang.Object
   |
   +----com.sun.java.swing.JTreeSelectionModel

public class JTreeSelectionModel
extends Object
implements TreeSelectionModel
Implementation of TreeSelectionModel. Listeners are notified whenever the paths in the selection change, not the rows. If you directly add paths to an instance of this class the path may not be visible. For this reason it is preferrable that you use the path manipulation methods provided by JTree that insure the path is visible. In order to be able to track row changes you may wish to become a listener for expansion events on the tree and test for changes from there.


Variable Index

 o listSelectionModel
Handles maintaining the list selection model.
 o rowMapper
Provides a row for a given path.
 o selection
Paths that are currently selected.
 o selectionListener
Event multicaster.

Constructor Index

 o JTreeSelectionModel()

Method Index

 o addSelectionPath(JTreePath)
Adds path to the current selection.
 o addSelectionPaths(JTreePath[])
Adds paths to the current selection.
 o addTreeSelectionListener(TreeSelectionListener)
Adds x to the list of listeners that are notified each time the selection changes.
 o clearSelection()
Empties the current selection.
 o getMaxSelectionRow()
Gets the last selected row.
 o getMinSelectionRow()
Gets the first selected row.
 o getRowMapper()
Returns the RowMapper instance that is able to map a path to a row.
 o getSelectionCount()
Returns the number of paths that are selected.
 o getSelectionPath()
Returns the first path in the selection.
 o getSelectionPaths()
Returns the paths in the selection.
 o getSelectionRows()
Returns all of the currently selected rows.
 o insureUniqueness()
Insures that all the elements in path are unique.
 o isPathSelected(JTreePath)
Returns true if the path, path, is in the current selection.
 o isRowSelected(int)
Returns true if the row identitifed by row is selected.
 o isSelectionEmpty()
Returns true if the selection is currently empty.
 o notifyPathChange(Vector)
Notifies listeners of a change in path.
 o removeSelectionPath(JTreePath)
Removes path from the selection.
 o removeSelectionPaths(JTreePath[])
Removes paths from the selection.
 o removeTreeSelectionListener(TreeSelectionListener)
Removes x from the list of listeners that are notified each time the selection changes.
 o resetRowSelection()
Recalculates what rows are selected by asking the RowMapper for the row for each path.
 o setRowMapper(RowMapper)
Sets the RowMapper instance.
 o setSelectionPath(JTreePath)
Sets the selection to path.
 o setSelectionPaths(JTreePath[])
Sets the selection to the paths in paths.

Variables

 o selection
 public JTreePath selection[]
Paths that are currently selected. Will be null if nothing is currently selected.

 o selectionListener
 protected TreeSelectionListener selectionListener
Event multicaster.

 o rowMapper
 protected RowMapper rowMapper
Provides a row for a given path.

 o listSelectionModel
 protected JListSelectionModel listSelectionModel
Handles maintaining the list selection model.

Constructors

 o JTreeSelectionModel
 public JTreeSelectionModel()

Methods

 o setRowMapper
 public void setRowMapper(RowMapper newMapper)
Sets the RowMapper instance. This instance is used to determine what row corresponds to what path.

 o getRowMapper
 public RowMapper getRowMapper()
Returns the RowMapper instance that is able to map a path to a row.

 o setSelectionPath
 public void setSelectionPath(JTreePath path)
Sets the selection to path. If this represents a change, then the PathSelectionListeners are notified.

Parameters:
path - new path to select
 o setSelectionPaths
 public void setSelectionPaths(JTreePath paths[])
Sets the selection to the paths in paths. If this represents a change the PathSelectionListeners are notified. Potentially paths will be held by the reciever, in other words don't change any of the objects in the array once passed in.

Parameters:
paths - new selection.
 o addSelectionPath
 public void addSelectionPath(JTreePath path)
Adds path to the current selection. If path is not currently in the selection the PathSelectionListeners are notified.

Parameters:
path - the new path to add to the current selection.
 o addSelectionPaths
 public void addSelectionPaths(JTreePath paths[])
Adds paths to the current selection. If any of the paths in paths are not currently in the selection the PathSelectionListeners are notified.

Parameters:
path - the new path to add to the current selection.
 o removeSelectionPath
 public void removeSelectionPath(JTreePath path)
Removes path from the selection. If path is in the selection The PathSelectionListeners are notified.

Parameters:
path - the path to remove from the selection.
 o removeSelectionPaths
 public void removeSelectionPaths(JTreePath paths[])
Removes paths from the selection. If any of the paths in paths are in the selection the PathSelectionListeners are notified.

Parameters:
path - the path to remove from the selection.
 o getSelectionPath
 public JTreePath getSelectionPath()
Returns the first path in the selection.

 o getSelectionPaths
 public JTreePath[] getSelectionPaths()
Returns the paths in the selection.

 o getSelectionCount
 public int getSelectionCount()
Returns the number of paths that are selected.

 o isPathSelected
 public boolean isPathSelected(JTreePath path)
Returns true if the path, path, is in the current selection.

 o isSelectionEmpty
 public boolean isSelectionEmpty()
Returns true if the selection is currently empty.

 o clearSelection
 public void clearSelection()
Empties the current selection. If this represents a change in the current selection, the selection listeners are notified.

 o addTreeSelectionListener
 public void addTreeSelectionListener(TreeSelectionListener x)
Adds x to the list of listeners that are notified each time the selection changes.

Parameters:
x - the new listener to be added.
 o removeTreeSelectionListener
 public void removeTreeSelectionListener(TreeSelectionListener x)
Removes x from the list of listeners that are notified each time the selection changes.

Parameters:
x - the listener to remove.
 o getSelectionRows
 public int[] getSelectionRows()
Returns all of the currently selected rows.

 o getMinSelectionRow
 public int getMinSelectionRow()
Gets the first selected row.

 o getMaxSelectionRow
 public int getMaxSelectionRow()
Gets the last selected row.

 o isRowSelected
 public boolean isRowSelected(int row)
Returns true if the row identitifed by row is selected.

 o resetRowSelection
 public void resetRowSelection()
Recalculates what rows are selected by asking the RowMapper for the row for each path.

 o notifyPathChange
 protected void notifyPathChange(Vector changedPaths)
Notifies listeners of a change in path.

 o insureUniqueness
 protected void insureUniqueness()
Insures that all the elements in path are unique. This does not check for a null selection!


All Packages  Class Hierarchy  This Package  Previous  Next  Index