Java Code Examples for javax.swing.JDialog#dispatchEvent()

The following examples show how to use javax.swing.JDialog#dispatchEvent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CapabilityResponsePopUp.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
public static void installEscapeCloseOperation(final JDialog dialog) {
	Action dispatchClosing = new AbstractAction() {
		public void actionPerformed(ActionEvent event) {
			dialog.dispatchEvent(new WindowEvent(
					dialog, WindowEvent.WINDOW_CLOSING
			));
		}
	};
	JRootPane root = dialog.getRootPane();
	root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
			escapeStroke, dispatchWindowClosingActionMapKey
	);
	root.getActionMap().put( dispatchWindowClosingActionMapKey, dispatchClosing
	);
}
 
Example 2
Source File: Utility.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Add a keyboard shortcut to allow ESC to close the dialog.
 *
 * @param dialog The dialog to be updated.
 */
public static void installEscapeCloseOperation(final JDialog dialog)
{
	JRootPane root = dialog.getRootPane();
	root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ESCAPE_STROKE, DISPATCH_WINDOW_CLOSING_ACTION_MAP_KEY);
	Action dispatchClosing = new AbstractAction()
	{
		@Override
		public void actionPerformed(ActionEvent event)
		{
			dialog.dispatchEvent(new WindowEvent(dialog, WindowEvent.WINDOW_CLOSING));
		}
	};
	root.getActionMap().put(DISPATCH_WINDOW_CLOSING_ACTION_MAP_KEY, dispatchClosing);
}
 
Example 3
Source File: SwingUtils.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
public static void installEscapeCloseOperation(final JDialog dialog) {
	Action dispatchClosing = new AbstractAction() {
		public void actionPerformed(ActionEvent event) {
			dialog.dispatchEvent(new WindowEvent(dialog, WindowEvent.WINDOW_CLOSING));
		}
	};
	JRootPane root = dialog.getRootPane();
	installCloseAction(dispatchClosing, root);
}
 
Example 4
Source File: DialogHelper.java    From Girinoscope with Apache License 2.0 5 votes vote down vote up
public static void installEscapeCloseOperation(final JDialog dialog) {
    @SuppressWarnings("serial")
    Action dispatchClosing = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent event) {
            dialog.dispatchEvent(new WindowEvent(dialog, WindowEvent.WINDOW_CLOSING));
        }
    };
    JRootPane root = dialog.getRootPane();
    root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ESCAPE_STROKE, DISPATCH_WINDOW_CLOSING_ACTION_MAP_KEY);
    root.getActionMap().put(DISPATCH_WINDOW_CLOSING_ACTION_MAP_KEY, dispatchClosing);
}
 
Example 5
Source File: Utility.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Add a keyboard shortcut to allow ESC to close the dialog.
 *
 * @param dialog The dialog to be updated.
 */
public static void installEscapeCloseOperation(final JDialog dialog)
{
	JRootPane root = dialog.getRootPane();
	root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ESCAPE_STROKE, DISPATCH_WINDOW_CLOSING_ACTION_MAP_KEY);
	Action dispatchClosing = new AbstractAction()
	{
		@Override
		public void actionPerformed(ActionEvent event)
		{
			dialog.dispatchEvent(new WindowEvent(dialog, WindowEvent.WINDOW_CLOSING));
		}
	};
	root.getActionMap().put(DISPATCH_WINDOW_CLOSING_ACTION_MAP_KEY, dispatchClosing);
}
 
Example 6
Source File: View.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
public static void installEscapeCloseOperation(final JDialog dialog) {
    Action dispatchClosing = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent event) {
            dialog.dispatchEvent(new WindowEvent(
                    dialog, WindowEvent.WINDOW_CLOSING));
        }
    };
    JRootPane root = dialog.getRootPane();
    root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
            escapeStroke, dispatchWindowClosingActionMapKey);
    root.getActionMap().put(dispatchWindowClosingActionMapKey, dispatchClosing);
}