List of usage examples for java.awt.event KeyEvent VK_ESCAPE
int VK_ESCAPE
To view the source code for java.awt.event KeyEvent VK_ESCAPE.
Click Source Link
From source file:com.mirth.connect.client.ui.codetemplate.CodeTemplateImportDialog.java
public CodeTemplateImportDialog(Frame owner, List<CodeTemplateLibrary> importLibraries, boolean unassignedCodeTemplates, boolean showCancelAlert) { super(owner, "Import Code Templates / Libraries", true); this.importLibraries = importLibraries; this.unassignedCodeTemplates = unassignedCodeTemplates; this.showCancelAlert = showCancelAlert; importLibraryMap = new HashMap<String, CodeTemplateLibrary>(); importCodeTemplateMap = new HashMap<String, CodeTemplate>(); initComponents();// w w w . ja va 2 s.c o m initLayout(); if (showCancelAlert) { setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent evt) { if (confirmClose()) { dispose(); } } }); ActionListener closeAction = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (confirmClose()) { dispose(); } } }; getRootPane().registerKeyboardAction(closeAction, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); } else { setDefaultCloseOperation(DISPOSE_ON_CLOSE); } updateErrorsAndWarnings(); setPreferredSize(new Dimension(420, 420)); pack(); setLocationRelativeTo(owner); setResizable(false); setVisible(true); }
From source file:org.kalypso.model.wspm.ui.action.selection.AbstractProfilePointSelectionWidget.java
@Override public void keyReleased(final KeyEvent e) { final int keyCode = e.getKeyCode(); switch (keyCode) { case KeyEvent.VK_ESCAPE: finish();//from ww w .ja va 2 s . com break; } }
From source file:com.callidusrobotics.swing.SwingConsole.java
@Override public String getline(final int maxLen, final Color foreground, final Color background) throws ArrayIndexOutOfBoundsException { final StringBuffer stringBuffer = new StringBuffer(maxLen); boolean keepPolling = true; while (keepPolling) { if (stringBuffer.length() < maxLen) { showCursor();/*from w ww .ja v a 2s . c o m*/ } else { hideCursor(); } render(); final char input = getKeyTyped(); switch (input) { case KeyEvent.VK_ENTER: keepPolling = false; break; case KeyEvent.VK_BACK_SPACE: if (stringBuffer.length() > 0) { stringBuffer.deleteCharAt(stringBuffer.length() - 1); moveCursor(cursorRow, cursorCol - 1); print(cursorRow, cursorCol, ' ', background, background); } break; case KeyEvent.CHAR_UNDEFINED: case KeyEvent.VK_DELETE: case KeyEvent.VK_ESCAPE: // ignore these characters break; default: if (stringBuffer.length() < maxLen) { stringBuffer.append(input); print(cursorRow, cursorCol, input, foreground, background); moveCursor(cursorRow, cursorCol + 1); } } } hideCursor(); render(); return stringBuffer.toString(); }
From source file:fxts.stations.util.preferences.EditAction.java
public void actionPerformed(ActionEvent aEvent) { JButton okButton = UIManager.getInst().createButton(); JButton cancelButton = UIManager.getInst().createButton(); final JDialog dialog = new JDialog(mEditorPanel.getParentDialog()); dialog.setTitle(mEditorPanel.getTitle()); JPanel editPanel = new JPanel(); JPanel buttonPanel = new JPanel(); JPanel mainPanel = new JPanel(); mainPanel.setLayout(UIFrontEnd.getInstance().getSideLayout()); //mainPanel.setLayout(new SideLayout()); //sets button panel buttonPanel.setLayout(UIFrontEnd.getInstance().getSideLayout()); okButton.setText(mResMan.getString("IDS_OK_BUTTON")); //okButton.setPreferredSize(new Dimension(80, 27)); GridBagConstraints sideConstraints = UIFrontEnd.getInstance().getSideConstraints(); sideConstraints.insets = new Insets(10, 10, 10, 10); sideConstraints.gridx = 0;/*from w w w . j a va2 s .c o m*/ sideConstraints.gridy = 0; ResizeParameterWrapper resizeParameter = UIFrontEnd.getInstance().getResizeParameter(); resizeParameter.init(0.5, 0.0, 0.5, 0.0); resizeParameter.setToConstraints(sideConstraints); buttonPanel.add(okButton, sideConstraints); cancelButton.setText(mResMan.getString("IDS_CANCEL_BUTTON")); //cancelButton.setPreferredSize(new Dimension(80, 27)); sideConstraints = UIFrontEnd.getInstance().getSideConstraints(); sideConstraints.insets = new Insets(10, 10, 10, 10); sideConstraints.gridx = 1; sideConstraints.gridy = 0; resizeParameter = UIFrontEnd.getInstance().getResizeParameter(); resizeParameter.init(0.5, 0.0, 0.5, 0.0); resizeParameter.setToConstraints(sideConstraints); buttonPanel.add(cancelButton, sideConstraints); //adds button panel sideConstraints = UIFrontEnd.getInstance().getSideConstraints(); sideConstraints.insets = new Insets(10, 10, 10, 10); sideConstraints.gridx = 0; sideConstraints.gridy = 1; resizeParameter = UIFrontEnd.getInstance().getResizeParameter(); resizeParameter.init(0.0, 1.0, 1.0, 1.0); resizeParameter.setToConstraints(sideConstraints); mainPanel.add(buttonPanel, sideConstraints); //sets edit panel final IEditor editor = mType.getEditor(); editor.setValue(mValue); editPanel.setLayout(UIFrontEnd.getInstance().getSideLayout()); sideConstraints = UIFrontEnd.getInstance().getSideConstraints(); resizeParameter = UIFrontEnd.getInstance().getResizeParameter(); resizeParameter.init(0.0, 0.0, 1.0, 1.0); resizeParameter.setToConstraints(sideConstraints); Component editComp = editor.getComponent(); //Mar 25 2004 - kav: added for right tab order at Font Chooser at java 1.4. if (editComp instanceof FontChooser) { FontChooser fc = (FontChooser) editComp; fc.setNextFocusedComp(okButton); } editPanel.add(editComp, sideConstraints); //adds editor panel sideConstraints = UIFrontEnd.getInstance().getSideConstraints(); sideConstraints.gridx = 0; sideConstraints.gridy = 0; resizeParameter = UIFrontEnd.getInstance().getResizeParameter(); resizeParameter.init(0.0, 0.0, 1.0, 1.0); resizeParameter.setToConstraints(sideConstraints); mainPanel.add(editPanel, sideConstraints); //adds main panel dialog.getContentPane().setLayout(UIFrontEnd.getInstance().getSideLayout()); //dialog.getContentPane().setLayout(new SideLayout()); sideConstraints = UIFrontEnd.getInstance().getSideConstraints(); sideConstraints.fill = GridBagConstraints.BOTH; resizeParameter = UIFrontEnd.getInstance().getResizeParameter(); resizeParameter.init(0.0, 0.0, 1.0, 1.0); resizeParameter.setToConstraints(sideConstraints); dialog.getContentPane().add(mainPanel, sideConstraints); //adds listeners to buttons okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent aEvent) { if (editor.getValue().equals(mValue)) { // } else { mValue = editor.getValue(); mEditorPanel.setValue(mValue); mEditorPanel.refreshControls(); mEditorPanel.setValueChanged(true); } dialog.setVisible(false); dialog.dispose(); } }); okButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "ExitAction"); okButton.getActionMap().put("ExitAction", new AbstractAction() { /** * Invoked when an action occurs. */ public void actionPerformed(ActionEvent aEvent) { editor.setValue(mValue); dialog.setVisible(false); dialog.dispose(); } }); okButton.requestFocus(); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent aEvent) { editor.setValue(mValue); dialog.setVisible(false); dialog.dispose(); } }); //dialog.setResizable(false); dialog.setModal(true); dialog.pack(); //sets minimal sizes for components Dimension dim = mainPanel.getSize(); mainPanel.setMinimumSize(dim); mainPanel.setPreferredSize(dim); //sets size of buttons Dimension dimOkButton = okButton.getSize(); Dimension dimCancelButton = cancelButton.getSize(); int nMaxWidth = dimOkButton.getWidth() > dimCancelButton.getWidth() ? (int) dimOkButton.getWidth() : (int) dimCancelButton.getWidth(); okButton.setPreferredSize(new Dimension(nMaxWidth, (int) dimOkButton.getHeight())); okButton.setSize(new Dimension(nMaxWidth, (int) dimOkButton.getHeight())); cancelButton.setPreferredSize(new Dimension(nMaxWidth, (int) dimCancelButton.getHeight())); cancelButton.setSize(new Dimension(nMaxWidth, (int) dimCancelButton.getHeight())); dialog.setLocationRelativeTo(dialog.getOwner()); dialog.setVisible(true); }
From source file:de.wusel.partyplayer.gui.PartyPlayer.java
private JComponent createMainComponent() { JPanel mainPanel = new JPanel(new MigLayout("fill", "[][50%][][50%]", "[] [] [] [] [grow]")); mainPanel.add(new JLabel(getText("layout.current.title"))); mainPanel.add(new JSeparator(), "growx"); mainPanel.add(new JLabel(getText("layout.next.title"))); mainPanel.add(new JSeparator(), "growx, wrap"); mainPanel.add(createPlayerPanel(), "grow, span 2"); mainPanel.add(createPlayListPanel(), "grow, hmax 100, span 2, wrap"); mainPanel.add(new JLabel(getText("layout.available.title"))); mainPanel.add(new JSeparator(), "growx, span, wrap"); final JTextField searchField = new JTextField(); searchField.addKeyListener(new KeyAdapter() { @Override/*from ww w . j ava2 s. c o m*/ public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { searchField.setText(null); table.setRowFilter(null); } try { table.setRowFilter( RowFilter.regexFilter("(?i)" + Pattern.quote(searchField.getText()), 0, 1, 3)); } catch (PatternSyntaxException ex) { table.setRowFilter(null); //do nothing } } }); mainPanel.add(new JLabel(getText("layout.search.label"))); mainPanel.add(searchField, "span, growx, wrap"); mainPanel.add(createSongPanel(), "span, grow"); return mainPanel; }
From source file:org.dishevelled.brainstorm.BrainStorm.java
/** * Initialize components./* ww w . j a v a 2 s .c o m*/ */ private void initComponents() { Font font = new Font(chooseFontName(), Font.PLAIN, fontSize); hiddenCursor = createHiddenCursor(); textArea = new JTextArea() { /** {@inheritDoc} */ protected void paintComponent(final Graphics graphics) { Graphics2D g2 = (Graphics2D) graphics; g2.setRenderingHint(KEY_FRACTIONALMETRICS, VALUE_FRACTIONALMETRICS_ON); g2.setRenderingHint(KEY_TEXT_ANTIALIASING, VALUE_TEXT_ANTIALIAS_LCD_HRGB); super.paintComponent(g2); } }; textArea.setFont(font); textArea.setOpaque(true); textArea.setCursor(hiddenCursor); textArea.setBackground(backgroundColor); textArea.setForeground(textColor); textArea.setRows(rows); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); // clear all input mappings InputMap inputMap = textArea.getInputMap(); while (inputMap != null) { inputMap.clear(); inputMap = inputMap.getParent(); } // re-add select default input mappings textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "insert-break"); textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "insert-tab"); textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), "delete-previous"); int keyMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, keyMask), "delete-previous-word"); // add new input mappings textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, keyMask), "increase-font-size"); textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, keyMask), "decrease-font-size"); textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_S, keyMask), "save"); textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "quit"); textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_Q, keyMask), "quit"); Action increaseFontSizeAction = new IncreaseFontSizeAction(); Action decreaseFontSizeAction = new DecreaseFontSizeAction(); Action saveAction = new SaveAction(); Action quitAction = new QuitAction(); textArea.getActionMap().put("increase-font-size", increaseFontSizeAction); textArea.getActionMap().put("decrease-font-size", decreaseFontSizeAction); textArea.getActionMap().put("save", saveAction); textArea.getActionMap().put("quit", quitAction); placeholder = Box.createGlue(); }
From source file:ru.apertum.qsystem.client.forms.FReception.java
/** * Creates new form FReception//from w ww . j av a 2 s.c o m * * @param netProperty */ public FReception(IClientNetProperty netProperty) { this.netProperty = netProperty; initComponents(); setTitle(getTitle() + " " + Uses.getLocaleMessage("project.name" + FAbout.getCMRC_SUFF())); //NOI18N try { setIconImage(ImageIO .read(FAdmin.class.getResource("/ru/apertum/qsystem/client/forms/resources/monitor.png"))); //NOI18N } catch (IOException ex) { System.err.println(ex); } // . Escape // ? esc getRootPane().registerKeyboardAction((ActionEvent e) -> { setVisible(false); }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); // trayIcon, .. setSituation() ? tray final JFrame fr = this; tray = QTray.getInstance(fr, "/ru/apertum/qsystem/client/forms/resources/monitor.png", getTitle()); //NOI18N tray.addItem(getLocaleMessage("messages.tray.showClient"), (ActionEvent e) -> { setVisible(true); setState(JFrame.NORMAL); }); tray.addItem("-", (ActionEvent e) -> { }); tray.addItem(getLocaleMessage("messages.tray.close"), (ActionEvent e) -> { dispose(); System.exit(0); }); int ii = 1; final ButtonGroup bg = new ButtonGroup(); final String currLng = Locales.getInstance().getLangCurrName(); for (String lng : Locales.getInstance().getAvailableLocales()) { final JRadioButtonMenuItem item = new JRadioButtonMenuItem( org.jdesktop.application.Application.getInstance(ru.apertum.qsystem.QSystem.class).getContext() .getActionMap(FReception.class, fr).get("setCurrentLang")); //NOI18N bg.add(item); item.setSelected(lng.equals(currLng)); item.setText(lng); // NOI18N item.setName("QRadioButtonMenuItem" + (ii++)); // NOI18N menuLangs.add(item); } treeServices.addTreeSelectionListener((TreeSelectionEvent e) -> { serviceListChange(); }); // ?? ??. listUsers.addListSelectionListener((ListSelectionEvent e) -> { userListChange(); }); }
From source file:ja.lingo.application.gui.main.describer.DescriberGui.java
public void keyTypedOnEditorPane(KeyEvent e) { if (KeyEvent.VK_ESCAPE == e.getKeyChar()) { model.requestFocusInNavigator(); } }
From source file:se.trixon.pacoma.ui.MainFrame.java
private void initActions() { mActionManager = ActionManager.getInstance().init(getRootPane().getActionMap(), getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)); InputMap inputMap = mPopupMenu.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); ActionMap actionMap = mPopupMenu.getActionMap(); Action action = new AbstractAction("HideMenu") { @Override// w w w. ja v a2s. c o m public void actionPerformed(ActionEvent e) { mPopupMenu.setVisible(false); } }; String key = "HideMenu"; actionMap.put(key, action); KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); inputMap.put(keyStroke, key); //about PomInfo pomInfo = new PomInfo(Pacoma.class, "se.trixon", "pacoma"); AboutModel aboutModel = new AboutModel(SystemHelper.getBundle(Pacoma.class, "about"), SystemHelper.getResourceAsImageIcon(MainFrame.class, "pacoma-icon.png")); aboutModel.setAppVersion(pomInfo.getVersion()); AboutPanel aboutPanel = new AboutPanel(aboutModel); action = AboutPanel.getAction(MainFrame.this, aboutPanel); getRootPane().getActionMap().put(ActionManager.ABOUT, action); //File newButton.setAction(mActionManager.getAction(ActionManager.NEW)); newMenuItem.setAction(mActionManager.getAction(ActionManager.NEW)); openButton.setAction(mActionManager.getAction(ActionManager.OPEN)); openMenuItem.setAction(mActionManager.getAction(ActionManager.OPEN)); closeButton.setAction(mActionManager.getAction(ActionManager.CLOSE)); closeMenuItem.setAction(mActionManager.getAction(ActionManager.CLOSE)); saveButton.setAction(mActionManager.getAction(ActionManager.SAVE)); saveMenuItem.setAction(mActionManager.getAction(ActionManager.SAVE)); saveAsButton.setAction(mActionManager.getAction(ActionManager.SAVE_AS)); saveAsMenuItem.setAction(mActionManager.getAction(ActionManager.SAVE_AS)); propertiesMenuItem.setAction(mActionManager.getAction(ActionManager.PROPERTIES)); propertiesButton.setAction(mActionManager.getAction(ActionManager.PROPERTIES)); quitMenuItem.setAction(mActionManager.getAction(ActionManager.QUIT)); //Edit undoMenuItem.setAction(mActionManager.getAction(ActionManager.UNDO)); undoButton.setAction(mActionManager.getAction(ActionManager.UNDO)); undoButton.setText(""); redoMenuItem.setAction(mActionManager.getAction(ActionManager.REDO)); redoButton.setAction(mActionManager.getAction(ActionManager.REDO)); redoButton.setText(""); //Tools optionsMenuItem.setAction(mActionManager.getAction(ActionManager.OPTIONS)); //Help helpMenuItem.setAction(mActionManager.getAction(ActionManager.HELP)); aboutMenuItem.setAction(mActionManager.getAction(ActionManager.ABOUT)); //Toolbar addButton.setAction(mActionManager.getAction(ActionManager.ADD)); clearButton.setAction(mActionManager.getAction(ActionManager.CLEAR)); regenerateButton.setAction(mActionManager.getAction(ActionManager.REGENERATE)); // startButton.setAction(mActionManager.getAction(ActionManager.START)); // cancelButton.setAction(mActionManager.getAction(ActionManager.CANCEL)); menuButton.setAction(mActionManager.getAction(ActionManager.MENU)); renderButton.setAction(mActionManager.getAction(ActionManager.START)); SwingHelper.clearTextButtons(menuButton); }
From source file:nz.govt.natlib.ndha.manualdeposit.dialogs.EnterEntityNameAndPrefix.java
private void txtEnterFilePrefixKeyPressed(java.awt.event.KeyEvent evt) { if (evt.getKeyCode() == KeyEvent.VK_ESCAPE) { cancel(); } }