List of usage examples for java.awt.event KeyEvent VK_ENTER
int VK_ENTER
To view the source code for java.awt.event KeyEvent VK_ENTER.
Click Source Link
From source file:plugin.notes.gui.NotesView.java
private void editorKeyTyped(KeyEvent evt) { editor.getCaretPosition();//from w ww. ja v a 2 s.c o m editor.getStyledDocument(); if (evt.getKeyChar() == KeyEvent.VK_BACK_SPACE) { handleBackspace(); } else if (evt.getKeyChar() == KeyEvent.VK_ENTER) { handleEnter(); } }
From source file:tufts.vue.RichTextBox.java
private static boolean isFinishEditKeyPress(KeyEvent e) { // if we hit return key either on numpad ("enter" key), or // with any modifier down except a shift alone (in case of // caps lock) complete the edit. return e.getKeyCode() == KeyEvent.VK_ENTER && (e.getKeyLocation() == KeyEvent.KEY_LOCATION_NUMPAD || (e.getModifiersEx() != 0 && !e.isShiftDown())) == true; //== false; // reversed logic of below description }
From source file:tax.MainForm.java
private void nameTextKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_nameTextKeyPressed if (evt.getKeyCode() == KeyEvent.VK_ENTER) { String text = nameText.getText(); if (text.equals("")) { Util.fadeInAndOut(nameText, Color.white); afmText.requestFocus();//from w w w .j av a 2s . c om return; } if (afmToName.containsKey(text)) { // Util.fadeInAndOut(afmText, Util.darkGreen); // Util.fadeInAndOut(nameText, Util.darkGreen); afmText.setText((String) afmToName.get(text)); addRowBut.doClick(); } else { Util.fadeInAndOut(nameText, Util.darkOrange); nameText.setText(""); } } }
From source file:tax.MainForm.java
private void nameTextSKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_nameTextSKeyPressed if (evt.getKeyCode() == KeyEvent.VK_ENTER) { if (!afmToName.containsKey(nameTextS.getText()) && !nameTextS.getText().equals("")) { afmTextS.setEnabled(true);/*from w w w.j a va2 s . c o m*/ afmTextS.requestFocus(); Util.fadeInAndOut(nameTextS, Util.darkGreen); } else { nameTextS.setText(""); Util.fadeInAndOut(nameTextS, Util.darkOrange); } } }
From source file:tax.MainForm.java
private void afmTextSKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_afmTextSKeyPressed if (evt.getKeyCode() == KeyEvent.VK_ENTER) { String text = afmTextS.getText(); if (text.length() == 9) { try { int num = Integer.parseInt(text); } catch (Exception e) { afmTextS.setText(""); return; }/* w w w .j av a2 s . c o m*/ // Util.fadeInAndOut(afmTextS, Util.darkGreen); addNameBut.doClick(); } else { Util.fadeInAndOut(afmTextS, Util.darkOrange); } } else if (!evt.isActionKey() && !evt.isAltDown() && !evt.isControlDown() && !evt.isShiftDown() && !evt.isMetaDown() && (evt.getKeyCode() != KeyEvent.VK_BACK_SPACE) && (evt.getKeyCode() != KeyEvent.VK_DELETE) && (evt.getKeyCode() != KeyEvent.VK_ESCAPE)) { EventQueue.invokeLater(new Runnable() { @Override public void run() { String text = afmTextS.getText(); int afmLength = text.length(); while (lastAFMTextSLength == afmLength) { try { Thread.sleep(100); System.out.println("text: " + text); System.out.println(lastAFMTextSLength + " " + afmLength); return; } catch (InterruptedException ex) { Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex); } text = afmTextS.getText(); afmLength = text.length(); } try { int num = Integer.decode(text); if (afmLength > 9) { if (text.length() > 0) afmTextS.setText(text.substring(0, afmLength - 1)); else afmTextS.setText(""); return; } } catch (Exception e) { if (text.length() > 0) afmTextS.setText(text.substring(0, afmLength - 1)); else afmTextS.setText(""); return; } lastAFMTextSLength = afmLength; } }); } }
From source file:ru.goodfil.catalog.ui.forms.CarsPanel.java
private void vechicleTypesListKeyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_INSERT) { createTypeBtnActionPerformed(null); }//from ww w .j a va 2s . co m if (e.getKeyCode() == KeyEvent.VK_DELETE) { removeTypeBtnActionPerformed(null); } if (e.getKeyCode() == KeyEvent.VK_SPACE) { editTypeBtnActionPerformed(null); } if (e.getKeyCode() == KeyEvent.VK_ENTER) { vechicleTypesListValueChanged(null); } }
From source file:ca.uhn.hl7v2.testpanel.ui.v2tree.Hl7V2MessageTree.java
private void handleKeyPress(KeyEvent theE) { int row = getSelectedRow(); if (row == -1) { return;/*w ww . j a v a 2s . co m*/ } if (theE.getKeyCode() == KeyEvent.VK_ENTER || theE.getKeyCode() == KeyEvent.VK_F2) { AbstractLayoutCache layout = ((OutlineModel) getModel()).getLayout(); TreePath path = layout.getPathForRow(row); TreeNodeBase baseObj = (TreeNodeBase) path.getLastPathComponent(); if (myTableModel.isCellEditable(baseObj, TreeRowModel.COL_VALUE)) { editCellAt(row, TreeRowModel.COL_VALUE + 1); theE.consume(); } } }
From source file:ru.goodfil.catalog.ui.forms.CarsPanel.java
private void manufactorsListKeyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_INSERT) { createManufactorBtnActionPerformed(null); }/* w ww .j ava 2s . co m*/ if (e.getKeyCode() == KeyEvent.VK_DELETE) { removeManufactorBtnActionPerformed(null); } if (e.getKeyCode() == KeyEvent.VK_SPACE) { editManufactorBtnActionPerformed(null); } if (e.getKeyCode() == KeyEvent.VK_ENTER) { manufactorsListValueChanged(null); } if ((e.getKeyCode() == KeyEvent.VK_X) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) { putObjectToMyClipboard(getSelectedManufactors()); this.setOperation(OPERATION_CUT); } if ((e.getKeyCode() == KeyEvent.VK_C) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) { putObjectToMyClipboard(getSelectedManufactors()); this.setOperation(OPERATION_COPY); } if ((e.getKeyCode() == KeyEvent.VK_V) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) { List<Manufactor> manufactors = new ArrayList<Manufactor>(); manufactors.addAll(getFromClipboardByType(Manufactor.class)); if (manufactors.size() > 0) { Long vechicleTypeIdNew = getSelectedVechicleTypeId(); Assert.notNull(vechicleTypeIdNew); if (getOperation() == OPERATION_COPY) { carsService.doCopyManufactors(manufactors, vechicleTypeIdNew); } if (getOperation() == OPERATION_CUT) { carsService.doCutManufactors(manufactors, vechicleTypeIdNew); } reReadManufactors(vechicleTypeIdNew); } } }
From source file:edu.ku.brc.af.ui.db.DatabaseLoginPanel.java
/** * Creates a Document listener so the UI is updated when the doc changes * @param uiComponent the text field to be changed *///from w ww . jav a2s . c o m protected void addKeyListenerFor(final JComponent comp, final boolean checkForRet) { class KeyAdp extends KeyAdapter { private boolean checkForRetLocal = false; public KeyAdp(final boolean checkForRetArg) { this.checkForRetLocal = checkForRetArg; } @Override public void keyReleased(KeyEvent e) { updateUIControls(); if (checkForRetLocal && e.getKeyCode() == KeyEvent.VK_ENTER) { doLogin(); } } } comp.addKeyListener(new KeyAdp(checkForRet)); }
From source file:org.jas.gui.MainWindow.java
private void registerKeyStrokeAction() { KeyStroke ctrlo = KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK); KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0); inputMap = getOpenButton().getInputMap(JButton.WHEN_IN_FOCUSED_WINDOW); inputMap.put(ctrlo, CTRL_O);// www. j av a2s. c o m inputMap.put(enter, ENTER); getOpenButton().getActionMap().put(CTRL_O, new ClickAction(getOpenButton())); getOpenButton().getActionMap().put(ENTER, new ClickAction(getOpenButton())); }