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.
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.