!752 p-awt { Action action = new AbstractAction("Do It") { public void actionPerformed(ActionEvent evt) { print("Yo!"); } }; // This is the component we will register the keyboard shortcut with. JFrame frame = showFrame(); JComponent pnl = frame.getRootPane(); // F1 KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0); // Register Action in component's ActionMap. pnl.getActionMap().put("Do It", action); pnl.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(keyStroke, "Do It"); }