javax.swing.JDialog#getRootPane ( )源码实例Demo

下面列出了javax.swing.JDialog#getRootPane ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ChatGameFontificator   文件: ChatWindow.java
/**
 * Does the work required to make the parameter JDialog be hidden when pressing escape
 * 
 * @param popup
 */
public static void setupHideOnEscape(final JDialog popup)
{
    Action aa = new AbstractAction()
    {
        private static final long serialVersionUID = 1L;

        public void actionPerformed(ActionEvent event)
        {
            popup.setVisible(false);
        }
    };
    final String mapKey = "escapePressed";
    JRootPane root = popup.getRootPane();
    root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escapeStroke, mapKey);
    root.getActionMap().put(mapKey, aa);
}
 
源代码2 项目: arcusplatform   文件: CapabilityResponsePopUp.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
			));
		}
	};
	JRootPane root = dialog.getRootPane();
	root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
			escapeStroke, dispatchWindowClosingActionMapKey
	);
	root.getActionMap().put( dispatchWindowClosingActionMapKey, dispatchClosing
	);
}
 
源代码3 项目: netbeans   文件: ProgressPanel.java
public void open(JComponent progressComponent) {
    holder.add(progressComponent, BorderLayout.CENTER);

    DialogDescriptor dd = new DialogDescriptor(
            this,
            NbBundle.getMessage(ProgressPanel.class, "MSG_PleaseWait"),
            true,
            new Object[0],
            DialogDescriptor.NO_OPTION,
            DialogDescriptor.DEFAULT_ALIGN,
            null,
            null,
            true);
    dialog = DialogDisplayer.getDefault().createDialog(dd);
    if (dialog instanceof JDialog) {
        JDialog jDialog = ((JDialog)dialog);
        jDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
        JRootPane rootPane = jDialog.getRootPane();
        rootPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); // NOI18N
        rootPane.getActionMap().put("cancel", new AbstractAction() { // NOI18N
            public void actionPerformed(ActionEvent event) {
                if (cancelButton.isEnabled()) {
                    cancelButton.doClick();
                }
            }
        });
    }
    dialog.setResizable(false);
    dialog.setVisible(true);
}
 
源代码4 项目: netbeans   文件: ProgressPanel.java
public void open(JComponent progressComponent) {
    holder.add(progressComponent, BorderLayout.CENTER);

    DialogDescriptor dd = new DialogDescriptor(
            this,
            NbBundle.getMessage(ProgressPanel.class, "MSG_PleaseWait"),
            true,
            new Object[0],
            DialogDescriptor.NO_OPTION,
            DialogDescriptor.DEFAULT_ALIGN,
            null,
            null,
            true);
    dialog = DialogDisplayer.getDefault().createDialog(dd);
    if (dialog instanceof JDialog) {
        JDialog jDialog = ((JDialog) dialog);
        jDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
        JRootPane rootPane = jDialog.getRootPane();
        rootPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); // NOI18N
        rootPane.getActionMap().put("cancel", new AbstractAction() { // NOI18N
            @Override
            public void actionPerformed(ActionEvent event) {
                if (cancelButton.isEnabled()) {
                    cancelButton.doClick();
                }
            }
        });
    }
    dialog.setResizable(false);
    dialog.setVisible(true);
}
 
源代码5 项目: netbeans   文件: ProgressPanel.java
public void open(JComponent progressComponent) {
    holder.add(progressComponent, BorderLayout.CENTER);

    DialogDescriptor dd = new DialogDescriptor(
            this,
            NbBundle.getMessage (ProgressPanel.class, "MSG_PleaseWait"),
            true,
            new Object[0],
            DialogDescriptor.NO_OPTION,
            DialogDescriptor.DEFAULT_ALIGN,
            null,
            null,
            true);
    dialog = DialogDisplayer.getDefault().createDialog(dd);
    if (dialog instanceof JDialog) {
        JDialog jDialog = ((JDialog)dialog);
        jDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
        JRootPane rootPane = jDialog.getRootPane();
        rootPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); // NOI18N
        rootPane.getActionMap().put("cancel", new AbstractAction() { // NOI18N
            public void actionPerformed(ActionEvent event) {
                if (cancelButton.isEnabled()) {
                    cancelButton.doClick();
                }
            }
        });
    }
    dialog.setResizable(false);
    dialog.setVisible(true);
}
 
源代码6 项目: pcgen   文件: Utility.java
/**
 * 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);
}
 
源代码7 项目: WorldGrower   文件: SwingUtils.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));
		}
	};
	JRootPane root = dialog.getRootPane();
	installCloseAction(dispatchClosing, root);
}
 
源代码8 项目: Girinoscope   文件: DialogHelper.java
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);
}
 
源代码9 项目: pcgen   文件: Utility.java
/**
 * 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);
}
 
源代码10 项目: jpexs-decompiler   文件: View.java
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);
}