Hello all,
I would like to be able to double click on a row in a JTable, which
would brings up a dialog which allows the user to edit some of the
variables associated with the row selected (read: the double clicked row).
I know how to create a JTable, and use it. I also have the dialog code
ready, but not the connection between them. How do I detect a
double-click in the JTable, and how do I find out which cell (read: row)
has been the target of the click?

Signature
Kind regards,
Jan Danielsson
No one loves a cynic
Andrew McDonagh - 01 Jan 2005 23:18 GMT
> Hello all,
>
[quoted text clipped - 6 lines]
> double-click in the JTable, and how do I find out which cell (read: row)
> has been the target of the click?
Add a custom TableCellEditor object to the table. When its called, it
can show the dialog.
http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/table/TableCellEditor.html
Chas Douglass - 02 Jan 2005 00:31 GMT
> Hello all,
>
[quoted text clipped - 7 lines]
> double-click in the JTable, and how do I find out which cell (read:
> row) has been the target of the click?
table.addMouseListener(MouseAdapter() {
public void mouseClicked(MouseEvent event) {
if (event.getClickCount() == 2) {
Point clickPoint = event.getPoint();
int row = table.rowAtPoint(clickPoint);
int column = table.columnAtPoint(clickPoint);
if (row != -1 && column != -1) {
// dialog goes here
}
}
}
});
You're free, of course, to ignore the column if all you are interested in
is the row.
Hope that helps.
Chas Douglass