We help IT Professionals succeed at work.

mouse double click inside  JTABLE's columns

happyloman
happyloman asked
on
I have a 2 column table.

I would like a double click on the ANY CELL in the 1st column to result in Action_1, on ANY CELL in the second column to result in Action_2

I tried to hook a mouseadapter to the individual table columns, but the compiler complained:

    TableColumnModel tcm = table.getColumnModel();
    tcm.addMouseListener(new MouseAdapter() ......


Is there a way to do this? (I am already using the table header for a different callback)

by the way, the table is only enabled to be MULTI ROW SELECTION

THANKS

Comment
Watch Question

Author

Commented:
oh yeah, is there a way to do this without using mouse coordinates(mouse positions inside of the component)
CERTIFIED EXPERT
Commented:
You can use JTable.rowAtPoint(Point)/columnAtPoint(Point) to convert the mouse coordinates into the proper row/col of the table.

You want to add the adapter to the table, not the table column model.


Ovi

Commented:
so what do you need in fact ? the code for double click ?

Explore More ContentExplore courses, solutions, and other research materials related to this topic.