import java.awt.KeyboardFocusManager; import java.util.HashSet; import java.util.Set; import javax.swing.JButton; import javax.swing.KeyStroke; public class Main { public static void main(String[] argv) throws Exception { JButton component = new JButton("a"); Set set = new HashSet(component .getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS)); set.add(KeyStroke.getKeyStroke("F2")); component.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, set); } }