Libraryless. Click here for Pure Java version (1414L/10K/34K).
!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"); }
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
| ID | Author/Program | Comment | Date |
|---|---|---|---|
| 1252 | stefan | Works! | 2016-07-25 21:22:47 |
| Snippet ID: | #1003690 |
| Snippet name: | Test Window-Wide KeyListener on F1 |
| Eternal ID of this version: | #1003690/1 |
| Text MD5: | 11e1778353ab82961624aec907610e39 |
| Transpilation MD5: | d4d698453b6ee2f406be288ce1040a37 |
| Author: | stefan |
| Category: | javax / gui |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2016-07-25 21:22:05 |
| Source code size: | 562 bytes / 21 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 1173 / 1310 |
| Referenced in: | [show references] |