How can I find out which row in a JTable the user just clicked?
2 Answers
If you only ever care about listening to selections on the JTable:
jTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
int sel = jTable.getSelectedRow();
}
});
-
-
It should, but it also allows to more more with in reaction to the click. The "answer" will need some kind of listener so you know when to read the value. Jul 12, 2012 at 22:04