Package org.shaitu.easyphoto.ui

Source Code of org.shaitu.easyphoto.ui.EscapeFrame

/**
* COPYRIGHT. Harry Wu 2010. ALL RIGHTS RESERVED.
* Project: ThirdEye
* Author: Harry Wu <harrywu304@gmail.com>
* Created On: Oct 13, 2008 4:57:38 PM
*
*/
package org.shaitu.easyphoto.ui;

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

import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JRootPane;
import javax.swing.KeyStroke;

/**
* JFrame action in ESCAPE key pressed
* @author harry
*
*/
public class EscapeFrame extends JFrame {
  protected JRootPane createRootPane() {
    ActionListener actionListener = new ActionListener() {
      public void actionPerformed(ActionEvent actionEvent) {
        setVisible(false);
      }
    };
    JRootPane rootPane = new JRootPane();
    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    rootPane.registerKeyboardAction(actionListener, stroke,
        JComponent.WHEN_IN_FOCUSED_WINDOW);
    return rootPane;
  }
}
TOP

Related Classes of org.shaitu.easyphoto.ui.EscapeFrame

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.