Example usage for javax.swing JRootPane getToolkit

List of usage examples for javax.swing JRootPane getToolkit

Introduction

In this page you can find the example usage for javax.swing JRootPane getToolkit.

Prototype

public Toolkit getToolkit() 

Source Link

Document

Gets the toolkit of this component.

Usage

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*/
        }
    });
}