I would like to know how to capture the double click event on a JTable
Here is what I used for a single click:
m_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
ListSelectionModel rowSM = m_table.getSelectionModel();
rowSM.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
//Ignore extra messages.
if (e.getValueIsAdjusting()) {
return;
}
ListSelectionModel lsm = (ListSelectionModel) e.getSource();
if (lsm.isSelectionEmpty()) {
System.out.println("No rows are selected.");
}
else {
int selectedRow = lsm.getMinSelectionIndex();
System.out.println("Row " + selectedRow + " is now selected.");
// Display data from column
//selected
System.out.println((
String) m_table.getValueAt(m_table.getSelectedRow(), m_table.getSelectedColumn()));
// Display data from first
column of select row
System.out.println((String) m_table.getValueAt(m_table.getSelectedRow(), 0));
}
}
});
What I am realy looking for is the first column's data of the double clicked row.
Thanks