Java Swing Key Action addEscKeyAction(javax.swing.JComponent component, javax.swing.InputMap inputMap, javax.swing.Action action)

Here you can find the source of addEscKeyAction(javax.swing.JComponent component, javax.swing.InputMap inputMap, javax.swing.Action action)

Description

add Esc Key Action

License

Open Source License

Declaration

public static void addEscKeyAction(javax.swing.JComponent component, javax.swing.InputMap inputMap,
            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 a2 s  . co  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. addActionsToMap(Action[] list1, Map h)
  2. addCloseActionWithEscapeKey(final Window window, JRootPane rootPane)
  3. addCtrlEnterAction(JComponent comp, AbstractAction action)
  4. addEnterKey(JComponent control)
  5. addHotKey(int key, JComponent to, String actionName, Action action)
  6. addIcons(Action action, String[][] iconRoles)
  7. addStrokeToName(Action action)
  8. augmentList(Action[] list1, Action[] list2)