Java JDialog Escape Key addEscKeyAction(javax.swing.JDialog dialog, javax.swing.Action action)

Here you can find the source of addEscKeyAction(javax.swing.JDialog dialog, javax.swing.Action action)

Description

add Esc Key Action

License

Open Source License

Declaration

public static void addEscKeyAction(javax.swing.JDialog dialog, javax.swing.Action action) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static void addEscKeyAction(javax.swing.JDialog dialog, javax.swing.Action action) {
        addEscKeyAction(dialog.getRootPane(), action);
    }/*  ww  w .  ja v a  2  s.  c  o  m*/

    public static void addEscKeyAction(javax.swing.JWindow window, javax.swing.Action action) {
        addEscKeyAction(window.getRootPane(), action);
    }

    public static void addEscKeyAction(javax.swing.JComponent component, javax.swing.Action action) {
        addEscKeyAction(component, component.getInputMap(javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW), action);
    }

    public static void addEscKeyAction(javax.swing.JComponent component, javax.swing.InputMap inputMap,
            javax.swing.Action action) {
        inputMap.put(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0, false), "ESC_ACTION");
        component.getActionMap().put("ESC_ACTION", action);
    }
}

Related

  1. addEscapeListener(final JDialog dialog)
  2. addEscapeListener(final JDialog dialog)
  3. addEscapeListener(final JDialog dialog, final boolean hide)
  4. addEscapeToCloseSupport(final JDialog dialog)
  5. addEscapeToCloseSupport(final JDialog dialog, final boolean fadeOnClose)
  6. closeOnEsc(final JDialog dlg)
  7. closeOnEsc(JDialog dialog)
  8. closeOnEscape(final JDialog dialog)
  9. closeOnEscapePressed(final JDialog dialog)