Java Code Examples for java.awt.event.KeyEvent#VK_ENTER
The following examples show how to use
java.awt.event.KeyEvent#VK_ENTER .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SqueakKeyboard.java From trufflesqueak with MIT License | 8 votes |
private static int mapSpecialKeyCode(final KeyEvent e) { //@formatter:off switch(e.getExtendedKeyCode()) { case KeyEvent.VK_BACK_SPACE: return 8; case KeyEvent.VK_TAB: return 9; case KeyEvent.VK_ENTER: return 13; case KeyEvent.VK_ESCAPE: return 27; case KeyEvent.VK_SPACE: return 32; case KeyEvent.VK_PAGE_UP: return 11; case KeyEvent.VK_PAGE_DOWN: return 12; case KeyEvent.VK_END: return 4; case KeyEvent.VK_HOME: return 1; case KeyEvent.VK_LEFT: return 28; case KeyEvent.VK_UP: return 30; case KeyEvent.VK_RIGHT: return 29; case KeyEvent.VK_DOWN: return 31; case KeyEvent.VK_INSERT: return 5; case KeyEvent.VK_DELETE: return 127; default: return -1; // Not a special key. } //@formatter:on }
Example 2
Source File: BoundingBoxWindow.java From Pixie with MIT License | 7 votes |
/** * Handle the keyboard events for closing the application: cancel and * save cases. * * @param key the key code */ private void handleCloseDialogKeys(int key) { switch (key) { case KeyEvent.VK_ESCAPE: // cancel the object being edited cancelObject(); break; case KeyEvent.VK_ENTER: // if the textfield id the focus owner, do not save the object if (jFTFBorder.isFocusOwner()) { break; } saveObject(); break; default: // do nothing break; } }
Example 3
Source File: AddressField.java From LoboBrowser with MIT License | 7 votes |
private void onKeyPressed(final KeyEvent event) { final AddressField urlComboBox = this; if (event.getKeyCode() == KeyEvent.VK_ENTER) { final String urlText = urlComboBox.getText(); if (urlText.length() != 0) { this.componentSource.navigateOrSearch(); } } }
Example 4
Source File: FmtSpaces.java From netbeans with Apache License 2.0 | 7 votes |
@Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_SPACE || e.getKeyCode() == KeyEvent.VK_ENTER) { if (e.getSource() instanceof JTree) { JTree tree = (JTree) e.getSource(); TreePath path = tree.getSelectionPath(); if (toggle(path)) { e.consume(); } } } }
Example 5
Source File: CodeDisplayModelExample.java From binnavi with Apache License 2.0 | 6 votes |
@Override public void keyPressedOrTyped(CodeDisplayCoordinate coordinate, KeyEvent event) { if (!event.isActionKey()) { switch (event.getKeyCode()) { case KeyEvent.VK_ENTER: break; default: String stringToEdit = data.get(coordinate.getRow()).get(coordinate.getColumn()).get(coordinate.getLine()); if (stringToEdit.length() < coordinate.getFieldIndex()) { stringToEdit = padRight(stringToEdit, coordinate.getFieldIndex()); } String newString = stringToEdit.substring(0, coordinate.getFieldIndex()) + event.getKeyChar() + stringToEdit.substring(coordinate.getFieldIndex()); data.get(coordinate.getRow()).get(coordinate.getColumn()) .set(coordinate.getLine(), newString); coordinate.setFieldIndex(coordinate.getFieldIndex() + 1); break; } } else { switch (event.getKeyCode()) { case KeyEvent.VK_DOWN: break; case KeyEvent.VK_UP: break; case KeyEvent.VK_LEFT: coordinate.setFieldIndex(coordinate.getFieldIndex() - 1); break; case KeyEvent.VK_RIGHT: coordinate.setFieldIndex(coordinate.getFieldIndex() + 1); break; } } }
Example 6
Source File: FileCompletionPopup.java From netbeans with Apache License 2.0 | 6 votes |
private boolean isCompletionKey (int keyCode, JTextField textField) { if (keyCode == KeyEvent.VK_ENTER || keyCode == KeyEvent.VK_TAB) { return true; } if (keyCode == KeyEvent.VK_RIGHT && (textField.getCaretPosition() >= (textField.getDocument().getLength() - 1))) { return true; } return false; }
Example 7
Source File: NewEntryFrameUtil.java From Zettelkasten with GNU General Public License v3.0 | 6 votes |
public static void checkSpelling(int key, javax.swing.JTextArea ta, Settings settingsObj, AutoKorrektur spellObj) { if (KeyEvent.VK_SPACE == key || KeyEvent.VK_PERIOD == key || KeyEvent.VK_COMMA == key || KeyEvent.VK_BRACELEFT == key || KeyEvent.VK_ENTER == key || KeyEvent.VK_OPEN_BRACKET == key || KeyEvent.VK_COLON == key || KeyEvent.VK_QUOTE == key) { if (ta != null) { try { int caret = ta.getCaretPosition(); String text = ta.getText(); if (settingsObj.getSpellCorrect()) { if (caret > 2) { int start = text.lastIndexOf(" ", caret - 2); int start2 = text.lastIndexOf(System.lineSeparator(), caret - 2); if (start2 > start) { start = start2; } String wrong = text.substring(start + 1, caret - 1); String correct = spellObj.getCorrectSpelling(wrong); if (correct != null) { StringBuilder sb = new StringBuilder(text); sb.replace(start + 1, caret - 1, correct); ta.setText(sb.toString()); caret = caret - wrong.length() + correct.length(); ta.setCaretPosition(caret); } } } if (KeyEvent.VK_QUOTE == key) { // TODO Anfrührungszeichen ersetzen // <ALT>+0132 bzw. // <ALT>+0147 typographische Anführungszeichen oben / unten hin. } } catch (IndexOutOfBoundsException | IllegalArgumentException ex) { } } } }
Example 8
Source File: IntTextField.java From Pixelitor with GNU General Public License v3.0 | 6 votes |
@Override public void keyTyped(KeyEvent e) { char c = e.getKeyChar(); if (!(Character.isDigit(c) || c == KeyEvent.VK_BACK_SPACE || c == KeyEvent.VK_ENTER || c == KeyEvent.VK_DELETE)) { if (c != 26) { // 26 occurs while undoing a change, should not beep getToolkit().beep(); } e.consume(); } }
Example 9
Source File: MiniEdit.java From netbeans with Apache License 2.0 | 5 votes |
private void fileTreeKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_fileTreeKeyReleased if (evt.getKeyCode() == KeyEvent.VK_ENTER) { open(); } }
Example 10
Source File: REPLEditor.java From sciview with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected void processKeyEvent(KeyEvent e) { if(executing) { e.consume(); return; } if(e.isControlDown() && e.getKeyCode() == KeyEvent.VK_UP && e.getID() == KeyEvent.KEY_RELEASED) { walk(false); e.consume(); return; } if(e.isControlDown() && e.getKeyCode() == KeyEvent.VK_DOWN && e.getID() == KeyEvent.KEY_RELEASED) { walk(true); e.consume(); return; } if(e.isControlDown() && e.getKeyCode() == KeyEvent.VK_ENTER && e.getID() == KeyEvent.KEY_RELEASED) { String text = getText(); if(text.length() == 0) { e.consume(); return; } if(text.endsWith("\n")) { System.out.println("Truncating whitespace"); text = text.substring(0, text.length()-1); } outputPane.append(">> " + text + "\n"); executing = true; String finalText = text; threadService().run(() -> { final ScriptContext ctx = repl.getInterpreter().getEngine().getContext(); ctx.setErrorWriter(outputPane.getOutputWriter()); ctx.setWriter(outputPane.getOutputWriter()); final boolean result = repl.evaluate(finalText); threadService().queue(() -> { executing = false; if (!result) { outputPane.append("Umm, error occured\n"); System.out.println("Umm, error occured"); } varsPane.update(); }); }); setText(""); e.consume(); } else { super.processKeyEvent(e); e.consume(); } }
Example 11
Source File: LuceneDataStoreSearchGUI.java From gate-core with GNU Lesser General Public License v3.0 | 5 votes |
public ExecuteQueryAction() { super("Search", MainFrame.getIcon("Search")); super.putValue(SHORT_DESCRIPTION, "Execute the query."); super.putValue(MNEMONIC_KEY, KeyEvent.VK_ENTER); }
Example 12
Source File: OutputTextPane.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
/** * When a user hits enter we'll open any file links that they're on. This is useful if the user is going to the next/previous link and want to open the current link. */ private void handleKeyPress(int keyCode) { if (allowsClickingFiles) { if (keyCode == KeyEvent.VK_ENTER) { int caretLocation = textPane.getCaretPosition(); if (caretLocation != -1) { FileLink fileLink = liveOutputParser.getFileLink(caretLocation); if (fileLink != null) { interaction.fileClicked(fileLink.getFile(), fileLink.getLineNumber()); } } } } }
Example 13
Source File: TelephoneTextField.java From Spark with Apache License 2.0 | 5 votes |
public void keyTyped(KeyEvent keyEvent) { if(keyEvent.getKeyChar() == KeyEvent.VK_ENTER){ if(pad != null){ pad.hide(); } return; } if(pad != null){ pad.numberEntered(keyEvent.getKeyChar()); } }
Example 14
Source File: JRegisterView.java From binnavi with Apache License 2.0 | 5 votes |
@Override public void keyPressed(final KeyEvent event) { if (event.getKeyCode() == KeyEvent.VK_RIGHT) { if (m_caretPosition != (2 * m_registerModel.getRegisterInformation(m_editedRegister) .getRegisterSize())) { m_caretPosition++; } event.consume(); // Consume the event to avoid scrolling m_caret.setVisible(true); repaint(); } else if (event.getKeyCode() == KeyEvent.VK_LEFT) { if (m_caretPosition != 0) { m_caretPosition--; } event.consume(); // Consume the event to avoid scrolling m_caret.setVisible(true); repaint(); } else if (event.getKeyCode() == KeyEvent.VK_ENTER) { if (m_editedRegister == -1) { if (m_highlightedRegister != -1) { enterEditMode(m_highlightedRegister); } } else { leaveEditMode(true); } repaint(); } else if (isHexChar(event.getKeyChar())) { final int regSize = m_registerModel.getRegisterInformation(m_editedRegister).getRegisterSize(); if (m_caretPosition == (2 * regSize)) { return; } // Get the input value final long val = hexToValue(event.getKeyChar()); // Four bits are relevant for each input character. final long relevantBits = (regSize * 8) - 4 - (m_caretPosition * 4); // Find a mask for the relevant bits final long mask = 0xFL << relevantBits; // Shift the input value into the correct bits. final long shiftedNew = val << relevantBits; // Calculate the new value. m_editValue = m_editValue.and(BigInteger.valueOf(~mask)).or(BigInteger.valueOf(shiftedNew)); m_caretPosition++; m_caret.setVisible(true); repaint(); } }
Example 15
Source File: RedditExtractorUI.java From wandora with GNU General Public License v3.0 | 5 votes |
private void subredditSearchFieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_subredditSearchFieldKeyPressed if (evt.getKeyCode() == KeyEvent.VK_ENTER) { this.populateSubredditSearch(); } }
Example 16
Source File: LogPanel.java From Robot-Overlord-App with GNU General Public License v2.0 | 5 votes |
/** * Handle the key-released event from the text field. */ @Override public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { robot.sendCommand(commandLineText.getText()); commandLineText.setText(""); } }
Example 17
Source File: CsvTableEditorKeyListener.java From intellij-csv-validator with Apache License 2.0 | 5 votes |
@Override public void keyReleased(KeyEvent e) { switch (e.getKeyCode()) { case KeyEvent.VK_LEFT: if (e.isControlDown()) { csvTableEditor.tableEditorActions.addColumnBefore.actionPerformed(null); } break; case KeyEvent.VK_RIGHT: if (e.isControlDown()) { csvTableEditor.tableEditorActions.addColumnAfter.actionPerformed(null); } break; case KeyEvent.VK_UP: if (e.isControlDown()) { csvTableEditor.tableEditorActions.addRowBefore.actionPerformed(null); } break; case KeyEvent.VK_DOWN: if (e.isControlDown()) { csvTableEditor.tableEditorActions.addRowAfter.actionPerformed(null); } break; case KeyEvent.VK_ENTER: if (e.isControlDown() && csvTableEditor.isInCellEditMode()) { stopEditing.actionPerformed(null); } else if (!csvTableEditor.isInCellEditMode()) { startEditing.actionPerformed(null); } break; case KeyEvent.VK_DELETE: case KeyEvent.VK_BACK_SPACE: if (e.isControlDown() && e.isShiftDown()) { csvTableEditor.tableEditorActions.deleteColumn.actionPerformed(null); } else if (e.isControlDown()) { csvTableEditor.tableEditorActions.deleteRow.actionPerformed(null); } else if (!csvTableEditor.isInCellEditMode()) { csvTableEditor.tableEditorActions.clearCells.actionPerformed(null); } break; default: break; } }
Example 18
Source File: GradientSlider.java From PyramidShader with GNU General Public License v3.0 | 4 votes |
@Override public void keyPressed(KeyEvent e) { if(e.getKeyCode()==KeyEvent.VK_SPACE || e.getKeyCode()==KeyEvent.VK_ENTER) { ColorPickerPopup.this.setVisible(false); } }
Example 19
Source File: LoadSaveScreen.java From open-ig with GNU Lesser General Public License v3.0 | 4 votes |
@Override public boolean keyboard(KeyEvent e) { int code = e.getKeyCode(); char chr = e.getKeyChar(); if (code == KeyEvent.VK_ESCAPE) { if (confirmCancel.visible()) { confirmCancel.onClick.invoke(); } else { doBack(); } e.consume(); } else { if ((chr == 'x' || chr == 'X') && settingsMode == SettingsPage.VISUAL) { config.uiScale = 100; e.consume(); askRepaint(); } else if (maySave && settingsMode == SettingsPage.LOAD_SAVE) { if (code == KeyEvent.VK_ENTER) { doSave(); e.consume(); return true; } else if (code == KeyEvent.VK_BACK_SPACE) { if (saveText.length() > 0) { saveText = saveText.substring(0, saveText.length() - 1); } displaySaveText(); e.consume(); return true; } else if (commons.text().isSupported(chr)) { saveText += chr; displaySaveText(); e.consume(); return true; } } else { if (chr == 'o' || chr == 'O') { doBack(); e.consume(); } else if (chr == ' ' || chr == '1' || chr == '2' || chr == '3' ) { e.consume(); } } } return super.keyboard(e); }
Example 20
Source File: GetMasterPasswordDialog.java From megabasterd with GNU General Public License v3.0 | 3 votes |
private void current_pass_textfieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_current_pass_textfieldKeyPressed if (evt.getKeyCode() == KeyEvent.VK_ENTER) { ok_buttonActionPerformed(null); } }