Search in sources :

Example 76 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 77 with KeyStroke

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

the class RegistrationsDialog 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 78 with KeyStroke

use of javax.swing.KeyStroke in project groovy-core by groovy.

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 79 with KeyStroke

use of javax.swing.KeyStroke in project javatari by ppeccin.

the class JComboBoxNim method setEscActionListener.

private void setEscActionListener() {
    KeyStroke escKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    Action escapeAction = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            closeAction();
        }

        private static final long serialVersionUID = 1L;
    };
    getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escKeyStroke, "ESC");
    getRootPane().getActionMap().put("ESC", escapeAction);
}
Also used : AbstractAction(javax.swing.AbstractAction) Action(javax.swing.Action) ActionEvent(java.awt.event.ActionEvent) KeyStroke(javax.swing.KeyStroke) AbstractAction(javax.swing.AbstractAction)

Example 80 with KeyStroke

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

the class DialogModifyCustomPage method init.

@Override
protected void init() {
    if (this.workingContext == null) {
        throw new IllegalStateException("A working Context should be set before setting the 'Add Dialog' visible.");
    }
    LOGGER.debug("Initializing modify Custom Page dialog for: {}", customPage);
    // 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 = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            DialogModifyCustomPage.this.setVisible(false);
            DialogModifyCustomPage.this.dispose();
        }
    };
    getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
    getRootPane().getActionMap().put("ESCAPE", escapeAction);
    getEnabledCheckBox().setSelected(customPage.isEnabled());
    getPageMatcherTextField().setText(customPage.getPageMatcher());
    getCustomPagePageMatcherLocationsCombo().setSelectedItem(customPage.getPageMatcherLocation());
    getRegexCheckBox().setSelected(customPage.isRegex());
    getCustomPageTypesCombo().setSelectedItem(customPage.getType());
    this.setConfirmButtonEnabled(true);
    this.pack();
}
Also used : ActionEvent(java.awt.event.ActionEvent) KeyStroke(javax.swing.KeyStroke) AbstractAction(javax.swing.AbstractAction)

Aggregations

KeyStroke (javax.swing.KeyStroke)194 ActionEvent (java.awt.event.ActionEvent)77 AbstractAction (javax.swing.AbstractAction)56 InputMap (javax.swing.InputMap)46 Action (javax.swing.Action)44 JRootPane (javax.swing.JRootPane)36 ActionListener (java.awt.event.ActionListener)27 JPanel (javax.swing.JPanel)20 ActionMap (javax.swing.ActionMap)17 JComponent (javax.swing.JComponent)16 KeyEvent (java.awt.event.KeyEvent)15 JMenuItem (javax.swing.JMenuItem)14 JScrollPane (javax.swing.JScrollPane)14 Point (java.awt.Point)13 JFrame (javax.swing.JFrame)12 JPopupMenu (javax.swing.JPopupMenu)12 WindowEvent (java.awt.event.WindowEvent)10 Dimension (java.awt.Dimension)9 MouseAdapter (java.awt.event.MouseAdapter)9 MouseEvent (java.awt.event.MouseEvent)9