1 | // keyCode = KeyEvent VK_... |
2 | static void registerCtrlKey(JComponent c, int keyCode, S name, final Runnable r) {
|
3 | Action action = abstractAction(name, r); |
4 | KeyStroke keyStroke = KeyStroke.getKeyStroke(keyCode, InputEvent.CTRL_MASK); |
5 | c.getActionMap().put(name, action); |
6 | c.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(keyStroke, name); |
7 | } |
8 | |
9 | static void registerCtrlKey(JFrame frame, int keyCode, S name, final Runnable r) {
|
10 | registerCtrlKey(frame.getRootPane(), keyCode, name, r); |
11 | } |
Began life as a copy of #1004136
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1005373 |
| Snippet name: | registerCtrlKey - Note: always registers a key for a whole JFrame! |
| Eternal ID of this version: | #1005373/1 |
| Text MD5: | 81cbcd80c8aea68104a376d5c4655c38 |
| Author: | stefan |
| Category: | javax / gui |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2016-11-10 00:32:39 |
| Source code size: | 502 bytes / 11 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 719 / 751 |
| Referenced in: | [show references] |