I need the right AcionListener
for my JTable
.
At program start there is no row selected by default. If I now select any row in this JTable
then the ActionListener
shall start.
Try this. I use a ListSelectionListener
and it works for me. I added a listener to the table Model
jTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent event) {
if (jTable.getSelectedRow() > -1) {
// print first column value from selected row
System.out.println(jTable.getValueAt(jTable.getSelectedRow(), 0).toString());
}
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With