Question

How can I find out which row in a JTable the user just clicked?

Was it helpful?

Solution

Try this:

aJTable.rowAtPoint(evt.getPoint());

OTHER TIPS

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();
    }
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top