1 | // key = 1 to 12 |
2 | static void registerCtrlFunctionKey(JFrame frame, int key, final Runnable r) {
|
3 | S name = "Ctrl+F" + key; |
4 | Action action = abstractAction(name, r); |
5 | JComponent pnl = frame.getRootPane(); |
6 | KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_F1+key-1, InputEvent.CTRL_MASK); |
7 | pnl.getActionMap().put(name, action); |
8 | pnl.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(keyStroke, name); |
9 | } |
Began life as a copy of #1003927
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: | #1004191 |
| Snippet name: | registerCtrlFunctionKey - register Ctrl + function key (F1...F12) for a whole JFrame |
| Eternal ID of this version: | #1004191/1 |
| Text MD5: | e2f11c4180bb77eab1aae048408acd09 |
| Author: | stefan |
| Category: | javax / gui |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2016-08-09 17:46:29 |
| Source code size: | 422 bytes / 9 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 763 / 771 |
| Referenced in: | [show references] |