public interface TreeSelectionModel
This interface represents the current state of the selection for the tree component. For information and examples of using tree selection models, see How to Use Trees in The Java Tutorial.
The state of the tree selection is characterized by
a set of TreePaths, and optionally a set of integers. The mapping
from TreePath to integer is done by way of an instance of RowMapper.
It is not necessary for a TreeSelectionModel to have a RowMapper to
correctly operate, but without a RowMapper getSelectionRows
will return null.
A TreeSelectionModel can be configured to allow only one
path (SINGLE_TREE_SELECTION) a number of
continguous paths (CONTIGUOUS_TREE_SELECTION) or a number of
discontiguous paths (DISCONTIGUOUS_TREE_SELECTION).
A RowMapper is used to determine if TreePaths are
contiguous.
In the absence of a RowMapper CONTIGUOUS_TREE_SELECTION and
DISCONTIGUOUS_TREE_SELECTION behave the same, that is they
allow any number of paths to be contained in the TreeSelectionModel.
For a selection model of CONTIGUOUS_TREE_SELECTION any
time the paths are changed (setSelectionPath,
addSelectionPath ...) the TreePaths are again checked to
make they are contiguous. A check of the TreePaths can also be forced
by invoking resetRowSelection. How a set of discontiguous
TreePaths is mapped to a contiguous set is left to implementors of
this interface to enforce a particular policy.
Implementations should combine duplicate TreePaths that are added to the selection. For example, the following code
treeSelectionModel.setSelectionPaths(paths);
treePath, and
not two copies of treePath.
The lead TreePath is the last path that was added (or set). The lead row is then the row that corresponds to the TreePath as determined from the RowMapper.
| 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(PropertyChangeListener listener)
Adds 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 set of selected TreePaths 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()
Returns the largest value obtained from the RowMapper for the current set of selected TreePaths. |
int |
getMinSelectionRow()
Returns the smallest value obtained from the RowMapper for the current set of selected TreePaths. |
RowMapper |
getRowMapper()
Returns the RowMapper instance that is able to map a TreePath to a row. |
int |
getSelectionCount()
Returns the number of paths that are selected. |
int |
getSelectionMode()
Returns the current selection mode, one of SINGLE_TREE_SELECTION,
CONTIGUOUS_TREE_SELECTION or
DISCONTIGUOUS_TREE_SELECTION. |
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 identified by row is selected. |
boolean |
isSelectionEmpty()
Returns true if the selection is currently empty. |
void |
removePropertyChangeListener(PropertyChangeListener listener)
Removes 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 set of selected TreePaths changes. |
void |
resetRowSelection()
Updates this object's mapping from TreePaths to rows. |
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 path. |
| Field Detail |
|---|
static final int SINGLE_TREE_SELECTION
static final int CONTIGUOUS_TREE_SELECTION
static final int DISCONTIGUOUS_TREE_SELECTION
| Method Detail |
|---|
void setSelectionMode(int mode)
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 SINGLE_TREE_SELECTION,
only one TreePath will remain selected. It is up to the particular
implementation to decide what TreePath remains selected.
int getSelectionMode()
SINGLE_TREE_SELECTION,
CONTIGUOUS_TREE_SELECTION or
DISCONTIGUOUS_TREE_SELECTION.
void setSelectionPath(TreePath path)
path is
null, this has the same effect as invoking clearSelection.
path - new path to selectvoid setSelectionPaths(TreePath[] paths)
paths is
null, this has the same effect as invoking clearSelection.
paths - new selectionvoid addSelectionPath(TreePath path)
path is null.
path - the new path to add to the current selectionvoid addSelectionPaths(TreePath[] paths)
paths is null.
paths - the new paths to add to the current selectionvoid removeSelectionPath(TreePath path)
path is null.
path - the path to remove from the selectionvoid removeSelectionPaths(TreePath[] paths)
paths
are in the selection, the TreeSelectionListeners are notified.
This method has no effect if paths is null.
paths - the path to remove from the selectionTreePath getSelectionPath()
RowMapper.
TreePath[] getSelectionPaths()
int getSelectionCount()
boolean isPathSelected(TreePath path)
path, is in the current
selection.
boolean isSelectionEmpty()
void clearSelection()
void setRowMapper(RowMapper newMapper)
RowMapper getRowMapper()
int[] getSelectionRows()
int getMinSelectionRow()
int getMaxSelectionRow()
boolean isRowSelected(int row)
row is selected.
void resetRowSelection()
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.
int getLeadSelectionRow()
TreePath getLeadSelectionPath()
void addPropertyChangeListener(PropertyChangeListener listener)
A PropertyChangeEvent will get fired when the selection mode changes.
listener - the PropertyChangeListener to be addedvoid removePropertyChangeListener(PropertyChangeListener listener)
listener - the PropertyChangeListener to be removedvoid addTreeSelectionListener(TreeSelectionListener x)
x - the new listener to be addedvoid removeTreeSelectionListener(TreeSelectionListener x)
x - the listener to removeCes informations proviennent du site de http://java.sun.com
Le contenu de cette page provient du site de Sun, et est généré depuis un cache sur l'infobrol après certains traitements automatisés. La présentation peut donc différer du document original, mais le contenu aussi. Vous pouvez utiliser ce bouton pour afficher la page originale du site de Sun :
Maintenir les pages en cache sur différents sites peut offrir plus de disponibilité.
Chaque page est indexée dans la base de donnée, ce qui permet de retrouver facilement les informations, au moyen des sommaires, du moteur de recherche interne, etc.
Des facilités sont mises en place pour que les membres de l'infobrol puissent effectuer des traductions en français des différents documents. Ceci devrait permettre aux débutants en programmation Java de consulter les API en français s'ils maîtrisent moins bien la langue de Shakespeare. Dans le cas où une traduction a été soumise, elle est disponible au moyen d'un lien en bas de page. Si la traduction a été validée, la page s'affiche par défaut en français, et un lien en bas de page permet d'atteindre la version en anglais.
Le code sur l'infobrol est automatiquement coloré selon la syntaxe, et les différents mots clés sont transformés en liens pour accéder rapidement aux informations.
Vous avez la possibilité de partager vos expériences en proposant vos propres extraits de code en utilisant le bouton "ajouter un commentaire" en bas de page. Si vous visitez simplement l'infobrol, vous avez déjà accès à cette fonction, mais si vous étes membre du brol, vous pouvez en plus utiliser des boutons supplémentaires de mise en forme, dont la coloration automatique de vos extraits de codes.
Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.
7 mots clés dont 0 définis manuellement (plus d'information...).
Avertissement
Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.
Recherche (afficher)
Utilisateur (masquer)
Navigation (masquer)
Apparence (afficher)
Stats (afficher)
Citation (masquer)