Detect double click on a row of a table

Hello

I can add ListSelectionListerner to detect a selection on a row of a table as:

myTable.getSelectionModel().addListSelectionListener(new MyRowListener());

class MyRowListener implements ListSelectionListener {

public void valueChanged(ListSelectionEvent e) {

...}

How i can detec a double click on this row so that I do something when use double click on a row

thanks

shuhu

[433 byte] By [suhua] at [2007-11-27 8:51:00]
# 1

It would be easier to implement a mouse listener against the table rather than a list selection listener as follows: -

jTable.addMouseListener(new java.awt.MouseAdapter() {

public void mousePressed(java.awt.event.MouseEvent e) {

if (e.getButton == 1 && e.getClickCount() == 2) {

// Your Code Here

}

}

});

To get the selected row just use jTable.getSelectedRow() and you can check if the selected row is -1 to ensure you have a valid row

c0demonk3ya at 2007-7-12 21:03:26 > top of Java-index,Desktop,Core GUI APIs...