Reputation: 18521
I am using addMouseListener (that has many method to implement)
and can add add keyListener also.
Is there a better way to get a row selected listener?
Thanks.
Upvotes: 3
Views: 21985
Reputation: 146
have you tried?
jTable1.getModel().addTableModelListener(new TableModelListener() {
public void tableChanged(TableModelEvent e) {
if(e.getType() == e.UPDATE){
System.out.println(e.getColumn());
System.out.println(e.getFirstRow());
System.out.println(e.getLastRow());
}
}
});
@assylias yeah there is a selected in the question not a changed. My mistake misread the question.
Upvotes: 9
Reputation: 328608
If you want to listen to row selection changes (i.e. not value changes inside the row), you can use this: yourJTable.getSelectionModel().addListSelectionListener(yourListener);
?
Upvotes: 33