24 Şubat 2012 Cuma

Changing Jtable Focus Keys

JTable uses ctrl+tab and ctrl+shift+tab key combinations to change focus
to other components by default.

You can change it to expected tab and shift+tab combination with the
following code snippet:

JTable table = ...

Set forwKeys = new HashSet();
forwKeys.add(AWTKeyStroke.getAWTKeyStroke("TAB"));
table.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forwKeys);

Set backKeys = new HashSet();
backKeys.add(AWTKeyStroke.getAWTKeyStroke("shift TAB"));
table.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, backKeys);