public static void fixTabKeys(final JComponent component){
  final Set<AWTKeyStroke> forward=new HashSet<AWTKeyStroke>(component.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
  forward.add(KeyStroke.getKeyStroke("TAB"));
  component.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,forward);
  final Set<AWTKeyStroke> backward=new HashSet<AWTKeyStroke>(component.getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));
  backward.add(KeyStroke.getKeyStroke("shift TAB"));
  component.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,backward);
}

public static void fixTabKeys ( final JComponent component ) { final Set < AWTKeyStroke > forward = new HashSet < AWTKeyStroke > ( component . getFocusTraversalKeys ( KeyboardFocusManager . FORWARD_TRAVERSAL_KEYS ) ) ; forward . add ( KeyStroke . getKeyStroke ( "TAB" ) ) ; component . setFocusTraversalKeys ( KeyboardFocusManager . FORWARD_TRAVERSAL_KEYS , forward ) ; final Set < AWTKeyStroke > backward = new HashSet < AWTKeyStroke > ( component . getFocusTraversalKeys ( KeyboardFocusManager . BACKWARD_TRAVERSAL_KEYS ) ) ; backward . add ( KeyStroke . getKeyStroke ( "shift TAB" ) ) ; component . setFocusTraversalKeys ( KeyboardFocusManager . BACKWARD_TRAVERSAL_KEYS , backward ) ; }
this method sets the focustraversalkeys for a component to be the standard keys . use this on tables or textareas where you want the tab keys to leave the control .
