Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Swing 1.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.swing.tree
Interface TreeSelectionModel

All Known Implementing Classes:
  DefaultTreeSelectionModel

public abstract interface TreeSelectionModel

This interface represents the current state of the selection for the tree component. It will keep track of the selected rows, but in order to select by row you will need to go directly to the tree.

Field Summary
`static int` | `CONTIGUOUS_TREE_SELECTION` Selection can only be contiguous.
`static int` | `DISCONTIGUOUS_TREE_SELECTION` Selection can contain any number of items that are not necessarily contiguous.
`static int` | `SINGLE_TREE_SELECTION` Selection can only contain one path at a time.

Method Summary
`void` | `addPropertyChangeListener(java.beans.PropertyChangeListener listener)` Add a PropertyChangeListener to the listener list.
`void` | `addSelectionPath(TreePath path)` Adds path to the current selection.
`void` | `addSelectionPaths(TreePath[] paths)` Adds paths to the current selection.
`void` | `addTreeSelectionListener(TreeSelectionListener x)` Adds x to the list of listeners that are notified each time the selection changes.
`void` | `clearSelection()` Empties the current selection.
`TreePath` | `getLeadSelectionPath()` Returns the last path that was added.
`int` | `getLeadSelectionRow()` Returns the lead selection index.
`int` | `getMaxSelectionRow()` Gets the last selected row.
`int` | `getMinSelectionRow()` Gets the first selected row.
`RowMapper` | `getRowMapper()` Returns the RowMapper instance that is able to map a path to a row.
`int` | `getSelectionCount()` Returns the number of paths that are selected.
`int` | `getSelectionMode()` Returns the selection mode.
`TreePath` | `getSelectionPath()` Returns the first path in the selection.
`TreePath[]` | `getSelectionPaths()` Returns the paths in the selection.
`int[]` | `getSelectionRows()` Returns all of the currently selected rows.
`boolean` | `isPathSelected(TreePath path)` Returns true if the path, path, is in the current selection.
`boolean` | `isRowSelected(int row)` Returns true if the row identitifed by row is selected.
`boolean` | `isSelectionEmpty()` Returns true if the selection is currently empty.
`void` | `removePropertyChangeListener(java.beans.PropertyChangeListener listener)` Remove a PropertyChangeListener from the listener list.
`void` | `removeSelectionPath(TreePath path)` Removes path from the selection.
`void` | `removeSelectionPaths(TreePath[] paths)` Removes paths from the selection.
`void` | `removeTreeSelectionListener(TreeSelectionListener x)` Removes x from the list of listeners that are notified each time the selection changes.
`void` | `resetRowSelection()` Updates what rows are selected.
`void` | `setRowMapper(RowMapper newMapper)` Sets the RowMapper instance.
`void` | `setSelectionMode(int mode)` Sets the selection model, which must be one of SINGLE_TREE_SELECTION, CONTIGUOUS_TREE_SELECTION or DISCONTIGUOUS_TREE_SELECTION.
`void` | `setSelectionPath(TreePath path)` Sets the selection to path.
`void` | `setSelectionPaths(TreePath[] paths)` Sets the selection to the the paths.

Field Detail

### SINGLE_TREE_SELECTION

    public static final int SINGLE_TREE_SELECTION

  Selection can only contain one path at a time.

### CONTIGUOUS_TREE_SELECTION

    public static final int CONTIGUOUS_TREE_SELECTION

  Selection can only be contiguous. This will only be enforced if a RowMapper instance is provided.

### DISCONTIGUOUS_TREE_SELECTION

    public static final int DISCONTIGUOUS_TREE_SELECTION

  Selection can contain any number of items that are not necessarily contiguous.

Method Detail

### setSelectionMode

    public void setSelectionMode(int mode)

  Sets the selection model, which must be one of SINGLE_TREE_SELECTION, CONTIGUOUS_TREE_SELECTION or DISCONTIGUOUS_TREE_SELECTION.

### getSelectionMode

    public int getSelectionMode()

  Returns the selection mode.

### setSelectionPath

    public void setSelectionPath(TreePath path)

  Sets the selection to path. If this represents a change, then the TreeSelectionListeners are notified.
  Parameters:
    `path` - new path to select

### setSelectionPaths

    public void setSelectionPaths(TreePath[] paths)

  Sets the selection to the the paths. If this represents a change the TreeSelectionListeners are notified.
  Parameters:
    `paths` - new selection.

### addSelectionPath

    public void addSelectionPath(TreePath path)

  Adds path to the current selection. If path is not currently in the selection the TreeSelectionListeners are notified.
  Parameters:
    `path` - the new path to add to the current selection.

### addSelectionPaths

    public void addSelectionPaths(TreePath[] paths)

  Adds paths to the current selection. If any of the paths in paths are not currently in the selection the TreeSelectionListeners are notified.
  Parameters:
    `path` - the new path to add to the current selection.

### removeSelectionPath

    public void removeSelectionPath(TreePath path)

  Removes path from the selection. If path is in the selection The TreeSelectionListeners are notified.
  Parameters:
    `path` - the path to remove from the selection.

### removeSelectionPaths

    public void removeSelectionPaths(TreePath[] paths)

  Removes paths from the selection. If any of the paths in paths are in the selection the TreeSelectionListeners are notified.
  Parameters:
    `path` - the path to remove from the selection.

### getSelectionPath

    public TreePath getSelectionPath()

  Returns the first path in the selection.

### getSelectionPaths

    public TreePath[] getSelectionPaths()

  Returns the paths in the selection.

### getSelectionCount

    public int getSelectionCount()

  Returns the number of paths that are selected.

### isPathSelected

    public boolean isPathSelected(TreePath path)

  Returns true if the path, path, is in the current selection.

### isSelectionEmpty

    public boolean isSelectionEmpty()

  Returns true if the selection is currently empty.

### clearSelection

    public void clearSelection()

  Empties the current selection. If this represents a change in the current selection, the selection listeners are notified.

### setRowMapper

    public void setRowMapper(RowMapper newMapper)

  Sets the RowMapper instance. This instance is used to determine what row corresponds to what path.

### getRowMapper

    public RowMapper getRowMapper()

  Returns the RowMapper instance that is able to map a path to a row.

### getSelectionRows

    public int[] getSelectionRows()

  Returns all of the currently selected rows.

### getMinSelectionRow

    public int getMinSelectionRow()

  Gets the first selected row.

### getMaxSelectionRow

    public int getMaxSelectionRow()

  Gets the last selected row.

### isRowSelected

    public boolean isRowSelected(int row)

  Returns true if the row identitifed by row is selected.

### resetRowSelection

    public void resetRowSelection()

  Updates what rows are selected. This can be externally called in case the location of the paths change, but not the actual paths. You do not normally need to call this.

### getLeadSelectionRow

    public int getLeadSelectionRow()

  Returns the lead selection index. That is the last index that was added.

### getLeadSelectionPath

    public TreePath getLeadSelectionPath()

  Returns the last path that was added.

### addPropertyChangeListener

    public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)

  Add a PropertyChangeListener to the listener list. The listener is registered for all properties.

  A PropertyChangeEvent will get fired in response to an explicit setFont, setBackground, or SetForeground on the current component. Note that if the current component is inheriting its foreground, background, or font from its container, then no event will be fired in response to a change in the inherited property.

  Parameters:
    `listener` - The PropertyChangeListener to be added

### removePropertyChangeListener

    public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)

  Remove a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.
  Parameters:
    `listener` - The PropertyChangeListener to be removed

### 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.

### 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.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Swing 1.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Submit a bug or feature
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.