Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Activate menu on Ctrl+Shift+D

Status
Not open for further replies.

Echilon

Programmer
Feb 22, 2007
54
0
0
GB
I'm trying to create add a debug menu when the user presses Ctrl+Shift+D. I have a class which extends JFrame, and this is the code I'm using.

KeyStroke debugKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK & InputEvent.SHIFT_DOWN_MASK, false);
Action debugAction = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
someMethod();
}
};
this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(debugKeyStroke, "D");
this.getRootPane().getActionMap().put("D", debugAction);

I have another action set up to close the window when Escape is pressed which works perfectly, but I can't get this one to work.
 
Use this statement instead:

KeyStroke debugKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK + InputEvent.SHIFT_DOWN_MASK, false);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top