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();
}
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);
}
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);
}
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);
}
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);
}
Aggregations