How to prevent JTable from returning to the first row when Tab is pressed?
问题 How can I disable JTable's default behaviour of returning to the first row, when tab key is pressed in the last cell of the table? Instead the current cell should keep its focus. 回答1: The short answer: find the action that's bound to the Tab, wrap it into a custom action that delegates to the original only if not in the last cell and replace the original action with your custom implemenation. In code: KeyStroke keyStroke = KeyStroke.getKeyStroke("TAB"); Object actionKey = table.getInputMap