I am trying to add a column to a JTable with the following behaviour (similar to Windows Explorer and similar shells):
- The cell can be clicked once to select it, as usual.
- The cell can be double-clicked to perform a separate action (launching an external program.)
- The cell value (a string) can still be edited, by single-clicking a second time (after a pause) or by pressing F2 when the cell is highlighted.
Double-clicking must not trigger editing of the cell, but I would like to leave any other default editing triggers operational if possible.
I have tried adding a MouseListener
to the table, and consuming all MouseEvent
s, but this does not work - if I return true
from isCellEditable()
then my listener never receives any click events but if I return false
then F2 no longer works.
Can this be achieved using only event listeners? I would prefer not to mess with the PLAF functions if I can avoid it.