Search in sources :

Example 81 with KeyStroke

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

the class DialogAddCustomPage 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.");
    }
    // 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) {
            DialogAddCustomPage.this.setVisible(false);
            DialogAddCustomPage.this.dispose();
        }
    };
    getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
    getRootPane().getActionMap().put("ESCAPE", escapeAction);
    this.setConfirmButtonEnabled(true);
    this.pack();
}
Also used : ActionEvent(java.awt.event.ActionEvent) KeyStroke(javax.swing.KeyStroke) AbstractAction(javax.swing.AbstractAction)

Example 82 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();
    centerFrame();
    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 83 with KeyStroke

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

the class AbstractFormDialog method initialise.

private void initialise(boolean initView) {
    setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            clearAndHide();
        }
    });
    firstTime = true;
    if (initView) {
        initView();
    }
    // 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 = -8088438488574461587L;

        @Override
        public void actionPerformed(ActionEvent e) {
            clearAndHide();
        }
    };
    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) WindowAdapter(java.awt.event.WindowAdapter) AbstractAction(javax.swing.AbstractAction)

Example 84 with KeyStroke

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

the class DialogEditShortcut method save.

@Override
public void save() {
    KeyboardShortcut ksDup = this.getDuplicate();
    if (ksDup != null) {
        // used for another menu item, so remove it from that
        ksDup.setKeyStroke(null);
    }
    KeyStroke ks = getKeyStroke();
    shortcut.setKeyStroke(ks);
}
Also used : KeyStroke(javax.swing.KeyStroke)

Example 85 with KeyStroke

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

the class AbstractDialog method initialize.

/**
 * This method initializes this
 */
private void initialize() {
    this.setVisible(false);
    this.setIconImages(DisplayUtils.getZapIconImages());
    this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    if (Model.getSingleton().getOptionsParam().getViewParam().getWmUiHandlingOption() == 0) {
        this.setSize(300, 200);
    }
    this.setTitle(Constant.PROGRAM_NAME);
    // 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(AbstractDialog.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)

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