Search in sources :

Example 6 with KeyStroke

use of javax.swing.KeyStroke in project gitblit by gitblit.

the class EditUserDialog method createRootPane.

@Override
protected JRootPane createRootPane() {
    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    JRootPane rootPane = new JRootPane();
    rootPane.registerKeyboardAction(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            setVisible(false);
        }
    }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
    return rootPane;
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) KeyStroke(javax.swing.KeyStroke) JRootPane(javax.swing.JRootPane)

Example 7 with KeyStroke

use of javax.swing.KeyStroke in project gitblit by gitblit.

the class EditRegistrationDialog method createRootPane.

@Override
protected JRootPane createRootPane() {
    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    JRootPane rootPane = new JRootPane();
    rootPane.registerKeyboardAction(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            setVisible(false);
        }
    }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
    return rootPane;
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) KeyStroke(javax.swing.KeyStroke) JRootPane(javax.swing.JRootPane)

Example 8 with KeyStroke

use of javax.swing.KeyStroke in project zaproxy by zaproxy.

the class ManageAddOnsDialog method initialize.

/**
	 * This method initializes this
	 * 
	 */
private void initialize() {
    this.setTitle(Constant.messages.getString("cfu.manage.title"));
    //this.setContentPane(getJTabbed());
    this.setContentPane(getTopPanel());
    this.pack();
    if (Model.getSingleton().getOptionsParam().getViewParam().getWmUiHandlingOption() == 0) {
        this.setSize(700, 500);
    }
    state = State.IDLE;
    // Handle escape key to close the dialog
    KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
    AbstractAction escapeAction = new AbstractAction() {

        private static final long serialVersionUID = 3516424501887406165L;

        @Override
        public void actionPerformed(ActionEvent e) {
            dispatchEvent(new WindowEvent(ManageAddOnsDialog.this, WindowEvent.WINDOW_CLOSING));
        }
    };
    getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
    getRootPane().getActionMap().put("ESCAPE", escapeAction);
}
Also used : ActionEvent(java.awt.event.ActionEvent) WindowEvent(java.awt.event.WindowEvent) KeyStroke(javax.swing.KeyStroke) AbstractAction(javax.swing.AbstractAction)

Example 9 with KeyStroke

use of javax.swing.KeyStroke in project groovy by apache.

the class GroovyFilter method installAutoTabAction.

public static void installAutoTabAction(JTextComponent tComp) {
    tComp.getActionMap().put("GroovyFilter-autoTab", AUTO_TAB_ACTION);
    KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false);
    tComp.getInputMap().put(keyStroke, "GroovyFilter-autoTab");
}
Also used : KeyStroke(javax.swing.KeyStroke)

Example 10 with KeyStroke

use of javax.swing.KeyStroke in project processing by processing.

the class Toolkit method registerWindowCloseKeys.

// someone needs to be slapped
//static KeyStroke closeWindowKeyStroke;
/**
   * Return true if the key event was a Ctrl-W or an ESC,
   * both indicators to close the window.
   * Use as part of a keyPressed() event handler for frames.
   */
/*
  static public boolean isCloseWindowEvent(KeyEvent e) {
    if (closeWindowKeyStroke == null) {
      int modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
      closeWindowKeyStroke = KeyStroke.getKeyStroke('W', modifiers);
    }
    return ((e.getKeyCode() == KeyEvent.VK_ESCAPE) ||
            KeyStroke.getKeyStrokeForEvent(e).equals(closeWindowKeyStroke));
  }
  */
/**
   * Registers key events for a Ctrl-W and ESC with an ActionListener
   * that will take care of disposing the window.
   */
public static void registerWindowCloseKeys(JRootPane root, ActionListener disposer) {
    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    root.registerKeyboardAction(disposer, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
    int modifiers = awtToolkit.getMenuShortcutKeyMask();
    stroke = KeyStroke.getKeyStroke('W', modifiers);
    root.registerKeyboardAction(disposer, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
}
Also used : KeyStroke(javax.swing.KeyStroke)

Aggregations

KeyStroke (javax.swing.KeyStroke)68 ActionEvent (java.awt.event.ActionEvent)27 ActionListener (java.awt.event.ActionListener)15 AbstractAction (javax.swing.AbstractAction)13 JRootPane (javax.swing.JRootPane)13 Action (javax.swing.Action)10 InputMap (javax.swing.InputMap)9 WindowEvent (java.awt.event.WindowEvent)6 ActionMap (javax.swing.ActionMap)5 GridBagLayout (java.awt.GridBagLayout)4 Point (java.awt.Point)4 ArrayList (java.util.ArrayList)4 JMenuItem (javax.swing.JMenuItem)4 JPanel (javax.swing.JPanel)4 JScrollPane (javax.swing.JScrollPane)4 AWTKeyStroke (java.awt.AWTKeyStroke)3 Dimension (java.awt.Dimension)3 GridBagConstraints (java.awt.GridBagConstraints)3 Insets (java.awt.Insets)3 KeyEvent (java.awt.event.KeyEvent)3