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

21
LINES

< > BotCompany Repo | #1003690 // Test Window-Wide KeyListener on F1

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (1414L/10K/34K).

1  
!752
2  
3  
p-awt {
4  
  Action action = new AbstractAction("Do It") {
5  
    public void actionPerformed(ActionEvent evt) {
6  
      print("Yo!");
7  
    }
8  
  };
9  
  
10  
  // This is the component we will register the keyboard shortcut with.
11  
  JFrame frame = showFrame();
12  
  JComponent pnl = frame.getRootPane();
13  
  
14  
  // F1
15  
  KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0);
16  
  
17  
  // Register Action in component's ActionMap.
18  
  pnl.getActionMap().put("Do It", action);
19  
  
20  
  pnl.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(keyStroke, "Do It");
21  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

Comments [hide]

ID Author/Program Comment Date
1252 stefan Works! 2016-07-25 21:22:47

add comment

Snippet ID: #1003690
Snippet name: Test Window-Wide KeyListener on F1
Eternal ID of this version: #1003690/1
Text MD5: 11e1778353ab82961624aec907610e39
Transpilation MD5: d4d698453b6ee2f406be288ce1040a37
Author: stefan
Category: javax / gui
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-07-25 21:22:05
Source code size: 562 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 878 / 951
Referenced in: [show references]