List of usage examples for javax.swing JRootPane registerKeyboardAction
public void registerKeyboardAction(ActionListener anAction, KeyStroke aKeyStroke, int aCondition)
getActionMap()
and getInputMap()
for similar behavior. From source file:TDialog.java
protected JRootPane createRootPane() { ActionListener al = new ActionListener() { public void actionPerformed(ActionEvent ae) { hide();//from w w w . j a va 2s.c o m bCancel = true; } }; KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); JRootPane rootPane = super.createRootPane(); rootPane.registerKeyboardAction(al, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); return rootPane; }
From source file:EscapeDialog.java
protected JRootPane createRootPane() { ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { setVisible(false);/*from w ww .ja v a 2 s .c om*/ } }; JRootPane rootPane = new JRootPane(); KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); rootPane.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); return rootPane; }
From source file:au.org.ala.delta.ui.SearchDialog.java
@Override protected JRootPane createRootPane() { JRootPane rootPane = super.createRootPane(); KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); rootPane.registerKeyboardAction(new ActionListener() { @Override// w w w .j a v a 2s . c o m public void actionPerformed(ActionEvent e) { setVisible(false); } }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); return rootPane; }
From source file:com.mirth.connect.client.ui.ChannelTagDialog.java
protected JRootPane createRootPane() { JRootPane rootPane = new JRootPane(); KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0); rootPane.registerKeyboardAction(new ActionListener() { @Override// w w w. j av a2 s .com public void actionPerformed(ActionEvent e) { addButtonActionPerformed(null); } }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); return rootPane; }
From source file:org.pmedv.core.dialogs.AbstractNiceDialog.java
protected JRootPane createRootPane() { ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { result = OPTION_CANCEL;/*from ww w . j av a 2 s . co m*/ 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; }
From source file:com.projity.dialog.AbstractDialog.java
protected JRootPane createRootPane() { ActionListener escapeListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { onCancel();/* ww w . j a v a 2s .c o m*/ } }; ActionListener enterListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { onOk(); } }; ActionListener helpListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { onHelp(); } }; JRootPane rootPane = new JRootPane(); KeyStroke escapeStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); rootPane.registerKeyboardAction(escapeListener, escapeStroke, JComponent.WHEN_IN_FOCUSED_WINDOW); KeyStroke enterStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0); rootPane.registerKeyboardAction(enterListener, enterStroke, JComponent.WHEN_IN_FOCUSED_WINDOW); KeyStroke f1Stroke = KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0); rootPane.registerKeyboardAction(helpListener, f1Stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); return rootPane; }
From source file:com.mgmtp.perfload.loadprofiles.ui.dialog.SettingsDialog.java
@Override protected JRootPane createRootPane() { KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); JRootPane rp = super.createRootPane(); rp.registerKeyboardAction(new ActionListener() { @Override//from w w w . j a va 2 s .c o m public void actionPerformed(final ActionEvent e) { setVisible(false); } }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); return rp; }
From source file:com.anrisoftware.prefdialog.simpledialog.SimpleDialog.java
private void setupKeyboardActions() { JRootPane rootPane = dialog.getRootPane(); rootPane.setDefaultButton(getApproveButton()); rootPane.registerKeyboardAction(cancelAction, getKeyStroke(VK_ESCAPE, 0), WHEN_IN_FOCUSED_WINDOW); }
From source file:net.sf.jabref.gui.FindUnlinkedFilesDialog.java
/** * Close dialog when pressing escape// ww w. j a va 2 s . co m */ @Override protected JRootPane createRootPane() { ActionListener actionListener = actionEvent -> setVisible(false); JRootPane rPane = new JRootPane(); KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); rPane.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); return rPane; }
From source file:com.mgmtp.perfload.loadprofiles.ui.AppFrame.java
@Override protected JRootPane createRootPane() { KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); JRootPane rp = super.createRootPane(); rp.registerKeyboardAction(new ActionListener() { @Override//from ww w . j a v a2s.com public void actionPerformed(final ActionEvent e) { // reset and edit again when canceled editOrCancelLoadProfileEntity(); } }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); return rp; }