문제

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!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top