Java JRootPane registerEscapeAction(JRootPane pane, ActionListener l)

Here you can find the source of registerEscapeAction(JRootPane pane, ActionListener l)

Description

register key action when VK_ESCAPE pressed

License

Open Source License

Declaration

public static void registerEscapeAction(JRootPane pane, ActionListener l) 

Method Source Code

//package com.java2s;

import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import javax.swing.JComponent;

import javax.swing.JRootPane;
import javax.swing.KeyStroke;

public class Main {
    /**/* www.  j  a va2 s.  c  o m*/
     * register key action when VK_ESCAPE pressed
     */
    public static void registerEscapeAction(JRootPane pane, ActionListener l) {
        KeyStroke keyStroke = KeyStroke
                .getKeyStroke((char) KeyEvent.VK_ESCAPE);

        pane.registerKeyboardAction(l, keyStroke,
                JComponent.WHEN_IN_FOCUSED_WINDOW);
    }
}

Related

  1. closeOnEscape(final Window window, final JRootPane root)
  2. getRootPane(Window window)
  3. installEscapeBinding(final Window window, final JRootPane rootPane, final boolean dispose)
  4. isSecondaryWindow(JRootPane rp)
  5. makeWindowLeopardStyle(JRootPane rootPane)
  6. setCancelAction(RootPaneContainer c, Action cancelAction)
  7. setEscapeAction(JRootPane pane, Action action)