Java JComponent get focus traversal keys
import java.awt.BorderLayout; import java.awt.KeyboardFocusManager; import java.util.HashSet; import java.util.Set; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JTextField; import javax.swing.KeyStroke; public class Main { public static void main(String[] argv) throws Exception { JComponent component = new JTextField(); Set set = new HashSet(component.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS)); set.add(KeyStroke.getKeyStroke("F2")); component.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, set); /*from w w w . j a v a 2 s.com*/ JFrame f = new JFrame(); f.add(component, BorderLayout.NORTH); f.add(new JTextField(10), BorderLayout.SOUTH); f.setSize(300, 300); f.setVisible(true); } }