List of usage examples for javax.swing JDialog dispatchEvent
public final void dispatchEvent(AWTEvent e)
From source file:Main.java
public static void installEscapeCloseOperation(final JDialog dialog) { Action dispatchClosing = new AbstractAction() { public void actionPerformed(ActionEvent event) { dialog.dispatchEvent(new WindowEvent(dialog, WindowEvent.WINDOW_CLOSING)); }//from w w w. j a va 2 s.com }; JRootPane root = dialog.getRootPane(); root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ESCAPE_KEY_STROKE, ESCAPE_KEY); root.getActionMap().put(ESCAPE_KEY, dispatchClosing); }
From source file:com.adobe.aem.demomachine.gui.AemDemoUtils.java
public static void installEscapeCloseOperation(final JDialog dialog) { Action dispatchClosing = new AbstractAction() { private static final long serialVersionUID = 1L; public void actionPerformed(ActionEvent event) { dialog.dispatchEvent(new WindowEvent(dialog, WindowEvent.WINDOW_CLOSING)); }/* w w w . ja v a 2 s. com*/ }; JRootPane root = dialog.getRootPane(); root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escapeStroke, dispatchWindowClosingActionMapKey); root.getActionMap().put(dispatchWindowClosingActionMapKey, dispatchClosing); }
From source file:pcgen.gui2.tools.Utility.java
/** * Add a keyboard shortcut to allow ESC to close the dialog. * * @param dialog The dialog to be updated. *//* ww w .jav a 2 s. c o m*/ public static void installEscapeCloseOperation(final JDialog dialog) { JRootPane root = dialog.getRootPane(); root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escapeStroke, dispatchWindowClosingActionMapKey); Action dispatchClosing = new AbstractAction() { @Override public void actionPerformed(ActionEvent event) { dialog.dispatchEvent(new WindowEvent(dialog, WindowEvent.WINDOW_CLOSING)); } }; root.getActionMap().put(dispatchWindowClosingActionMapKey, dispatchClosing); }