Libraryless. Click here for Pure Java version (2732L/16K).
1 | // key = KeyEvent.VK_... |
2 | static void registerKeyCode(JFrame frame, int keyCode, O r) { |
3 | S name = "key " + keyCode; |
4 | Action action = abstractAction(name, r); |
5 | JComponent pnl = frame.getRootPane(); |
6 | KeyStroke keyStroke = KeyStroke.getKeyStroke(keyCode, 0); |
7 | pnl.getActionMap().put(name, action); |
8 | pnl.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(keyStroke, name); |
9 | } |
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: | 181 / 250 |
Version history: | 2 change(s) |
Referenced in: | [show references] |