Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

11
LINES

< > BotCompany Repo | #1005373 // registerCtrlKey - Note: always registers a key for a whole JFrame!

JavaX fragment (include)

// keyCode = KeyEvent VK_...
static void registerCtrlKey(JComponent c, int keyCode, S name, final Runnable r) {
  Action action = abstractAction(name, r);
  KeyStroke keyStroke = KeyStroke.getKeyStroke(keyCode, InputEvent.CTRL_MASK);
  c.getActionMap().put(name, action);
  c.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(keyStroke, name);
}

static void registerCtrlKey(JFrame frame, int keyCode, S name, final Runnable r) {
  registerCtrlKey(frame.getRootPane(), keyCode, name, r);
}

Author comment

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: 422 / 437
Referenced in: [show references]