Java Swing Key Action escapeKeyAction(JComponent component, javax.swing.AbstractAction abstractAction)

Here you can find the source of escapeKeyAction(JComponent component, javax.swing.AbstractAction abstractAction)

Description

escape Key Action

License

Apache License

Declaration

public static void escapeKeyAction(JComponent component, javax.swing.AbstractAction abstractAction) 

Method Source Code

//package com.java2s;
/*//from w  ww. j a  v  a  2s  . c  o m
 * codjo.net
 *
 * Common Apache License 2.0
 */

import java.awt.event.KeyEvent;

import javax.swing.JComponent;

import javax.swing.KeyStroke;

public class Main {
    static final String ESC_ACTION_KEY = "ESC_ACTION_KEY";

    public static void escapeKeyAction(JComponent component, javax.swing.AbstractAction abstractAction) {
        component.getRootPane().getActionMap().put(ESC_ACTION_KEY, abstractAction);
        component.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
                .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), ESC_ACTION_KEY);
    }
}

Related

  1. addHotKey(int key, JComponent to, String actionName, Action action)
  2. addIcons(Action action, String[][] iconRoles)
  3. addStrokeToName(Action action)
  4. augmentList(Action[] list1, Action[] list2)
  5. dispatchEvent(final KeyEvent ke, final Component comp)
  6. formatKeyStroke(final KeyStroke keyStroke)
  7. getActionID(final Action a)
  8. getActionInstanceName(Action delegate)
  9. getEscapeKeystroke()