Java AWT KeyboardFocusManager set focus backward transversal key
import java.awt.AWTKeyStroke; import java.awt.FlowLayout; import java.awt.KeyboardFocusManager; import java.util.HashSet; import java.util.Set; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.KeyStroke; public class Main { public static void main(String[] argv) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton component1 = new JButton("1"); JButton component2 = new JButton("2"); JButton component3 = new JButton("3"); frame.setLayout(new FlowLayout()); frame.add(component1);// w w w.j av a2 s . c o m frame.add(component2); frame.add(component3); frame.pack(); frame.setVisible(true); Set<AWTKeyStroke> set = new HashSet<AWTKeyStroke>(KeyboardFocusManager.getCurrentKeyboardFocusManager() .getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS)); set.add(KeyStroke.getKeyStroke("F3")); KeyboardFocusManager.getCurrentKeyboardFocusManager() .setDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, set); } }