Libraryless. Click here for Pure Java version (2732L/16K).
// key = KeyEvent.VK_... static void registerKeyCode(JFrame frame, int keyCode, O r) { S name = "key " + keyCode; Action action = abstractAction(name, r); JComponent pnl = frame.getRootPane(); KeyStroke keyStroke = KeyStroke.getKeyStroke(keyCode, 0); pnl.getActionMap().put(name, action); pnl.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(keyStroke, name); }
Began life as a copy of #1003691
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1031126 |
Snippet name: | registerKeyCode - register key for a whole JFrame |
Eternal ID of this version: | #1031126/3 |
Text MD5: | 469b5b1dcd0d0a299dd2e5960c697293 |
Transpilation MD5: | c9ab94229df507a197678266a00aba5b |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-05-07 16:38:40 |
Source code size: | 383 bytes / 9 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 180 / 248 |
Version history: | 2 change(s) |
Referenced in: | [show references] |