1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| ListSelectionModel cellSelectionModel = table.getSelectionModel();
cellSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
cellSelectionModel.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
System.out.println(e.getValueIsAdjusting());
if (e.getValueIsAdjusting()){
return ;
}else{
//ArrayList<String> selectedData = new ArrayList<String>();
String valeurRecup;
int[] selectedRow = table.getSelectedRows();
int[] selectedColumns = table.getSelectedColumns();
for (int i = 0; i < selectedRow.length; i++) {
for (int j = 0; j < selectedColumns.length; j++) {
valeurRecup = (String) table.getValueAt(selectedRow[i], selectedColumns[j]);
selectedData.add(valeurRecup);
System.out.println("Select: "+ selectedData.get(i));
selectedData.clear();
}
}
for (int i=0;i<selectedData.size();i++){
System.out.println("Select: "+ selectedData.get(i));
selectedData.clear();
}
selectedData.clear();
}
}
}); |
Partager