If someone edit the cell content of a JTable and press enter, the content is modified and the table selection moves to the next row.
Is that possible to forbid the JTable to go to the next row after a cell edition?
The reason is that my program synchronize some other widgets on cell selection using a ListSelectionListener, and I do not want to have the next row selected after editing the current cell.
The default binding for Enter is the Action
named selectNextRowCell
. To override the entry in the WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
input map, you'll need to supply a doNothing()
Action
, as suggested in How to Use Key Bindings: How to Make and Remove Key Bindings.
I'm not sure how exactly to do this, but I would look into ActionMap. You should be able to either modify or replace the Action that is mapped to the 'Enter' key.
Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With