sabrinam03
Messages postés7Date d'inscriptionvendredi 14 mars 2008StatutMembreDernière intervention19 avril 2008
-
15 mars 2008 à 12:39
uhrand
Messages postés491Date d'inscriptionsamedi 20 mai 2006StatutMembreDernière intervention15 juillet 2012
-
15 mars 2008 à 17:13
Bonjour,
je veux savoir comment attribuer un événement à une ligne de
tableau, càd quand je sélectionne une ligne, cette ligne s'affichera et
merci d'avance.
uhrand
Messages postés491Date d'inscriptionsamedi 20 mai 2006StatutMembreDernière intervention15 juillet 20129 15 mars 2008 à 17:13
1. ListSelectionListener:
rowListener = new ListSelectionListener() {
public void valueChanged(final ListSelectionEvent e) {
if(e.getValueIsAdjusting()) return;
System.out.println(table.getSelectedRow());
}
};
table.getSelectionModel().addListSelectionListener(rowListener);
2. On peut aussi attacher un ListSelectionListener au ColumnModel, alors on est informé également quand on sélectionne une autre colonne à l'intérieur d'une ligne: