Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionpublic class SelectionListener implements ListSelectionListener { JTable table; // It is necessary to keep the table since it is not possible // to determine the table from the event's source SelectionListener(JTable table) { this.table = table; } public void valueChanged(ListSelectionEvent e) { // If cell selection is enabled, both row and column change events are fired if (e.getSource() == table.getSelectionModel() && table.getRowSelectionAllowed()) { // Column selection changed : rien à faire dans ton cas } else if (e.getSource() == table.getColumnModel().getSelectionModel() && table.getColumnSelectionAllowed() ){ // Row selection changed : appel de la méthode selectionChanged(); } } }
SelectionListener listener = new SelectionListener(tonJTable); table.getSelectionModel().addListSelectionListener(listener); table.getColumnModel().getSelectionModel().addListSelectionListener(listener);
private void selectionChanged() { // ... code à exécuter lors de la modification de la sélection du jtable. }