List of usage examples for javax.swing JRootPane getToolkit
public Toolkit getToolkit()
From source file:Main.java
public static void setDontSaveButton(final JRootPane rp, final JButton b) { rp.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_D, 0), "dontSave"); rp.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(KeyStroke.getKeyStroke(KeyEvent.VK_D, rp.getToolkit().getMenuShortcutKeyMask()), "dontSave"); rp.getActionMap().put("dontSave", new AbstractAction() { private static final long serialVersionUID = 1L; public void actionPerformed(ActionEvent ev) { b.doClick();/*w ww .j a v a 2s .c o m*/ } }); }