Here you can find the source of addEscKeyAction(javax.swing.JDialog dialog, javax.swing.Action action)
public static void addEscKeyAction(javax.swing.JDialog dialog, javax.swing.Action action)
//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); } }