List of usage examples for java.awt.event KeyEvent getKeyChar
public char getKeyChar()
From source file:generadorqr.jifrNuevoQr.java
private void txtCantidadArticuloKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtCantidadArticuloKeyTyped char car = evt.getKeyChar(); if ((car < '0' || car > '9')) evt.consume();//from w w w .j a v a 2 s .c o m int limite = 3; if (txtCantidadArticulo.getText().length() == limite) evt.consume(); }
From source file:Provider.GoogleMapsStatic.TestUI.MySample.java
/** * @author jpmolinamatute/*from www. j a v a 2 s .co m*/ * * this method control the use the longitude and latitud using the numerical and arrows keyboard */ @Override public void keyPressed(KeyEvent arg0) { char keyLetter = arg0.getKeyChar(); int keyCode = arg0.getKeyCode(); setChange(); if (keyLetter == '8' || keyCode == 38) { setNorth(); startTaskAction(); } else if (keyLetter == '6' || keyCode == 39) { setEast(); startTaskAction(); } else if (keyLetter == '2' || keyCode == 40) { setSouth(); startTaskAction(); } else if (keyLetter == '4' || keyCode == 37) { setWest(); startTaskAction(); } else if (keyLetter == '7') { setNorthwest(); startTaskAction(); } else if (keyLetter == '9') { setNortheast(); startTaskAction(); } else if (keyLetter == '3') { setSoutheast(); startTaskAction(); } else if (keyLetter == '1') { setSouthwest(); startTaskAction(); } else if (keyLetter == 'Q' || keyLetter == 'q') { quitProgram(); } if (keyCode == 10) { startTaskAction(); } }
From source file:ec.util.chart.swing.JTimeSeriesChart.java
private void enableRevealObs() { chartPanel.addKeyListener(new KeyAdapter() { @Override//from w w w .j a va 2 s . c om public void keyPressed(KeyEvent e) { if (isInteractive() && e.getKeyChar() == 'r') { setRevealObs(true); } } @Override public void keyReleased(KeyEvent e) { if (isInteractive() && e.getKeyChar() == 'r') { setRevealObs(false); } } }); }
From source file:op.care.prescription.DlgOnDemand.java
private void cmbDocONKeyPressed(KeyEvent e) { final String searchKey = String.valueOf(e.getKeyChar()); GP doc = (GP) CollectionUtils.find(listAerzte, new Predicate() { @Override//from w w w . ja va 2 s . c om public boolean evaluate(Object o) { return o != null && ((GP) o).getName().toLowerCase().charAt(0) == searchKey.toLowerCase().charAt(0); } }); if (doc != null) { cmbDocON.setSelectedItem(doc); } }
From source file:net.fenyo.gnetwatch.GUI.BasicComponent.java
public void keyTyped(final KeyEvent e) { if (!manual_mode) { // automatic mode manual_now = System.currentTimeMillis(); manual_delay_per_interval = getDelayPerInterval(); manual_mode = true;/*from ww w .ja v a2s . c o m*/ } else { // manual mode if (e.getKeyChar() == 'a') { manual_mode = false; updateValues(); } if (e.getKeyChar() == 'n') { manual_now = System.currentTimeMillis(); updateValues(); } if (e.getKeyChar() == '<') { manual_delay_per_interval = manual_delay_per_interval * 2; updateValues(); } if (e.getKeyChar() == '>') { manual_delay_per_interval = manual_delay_per_interval / 2; updateValues(); } if (e.getKeyChar() == '+') { synchronized (sync_value_per_vinterval) { value_per_vinterval = value_per_vinterval / 2; } repaint(); } if (e.getKeyChar() == '-') { synchronized (sync_value_per_vinterval) { value_per_vinterval = value_per_vinterval * 2; } repaint(); } } }
From source file:org.tinymediamanager.ui.movies.MoviePanel.java
private void addKeyListener() { table.addKeyListener(new KeyListener() { private long lastKeypress = 0; private String searchTerm = ""; @Override/* w ww . j a va 2 s. c o m*/ public void keyTyped(KeyEvent arg0) { long now = System.currentTimeMillis(); if (now - lastKeypress > 500) { searchTerm = ""; } lastKeypress = now; if (arg0.getKeyChar() != KeyEvent.CHAR_UNDEFINED) { searchTerm += arg0.getKeyChar(); } if (StringUtils.isNotBlank(searchTerm)) { TableModel model = table.getModel(); for (int i = 0; i < model.getRowCount(); i++) { if (model.getValueAt(i, 0) instanceof Movie) { String title = ((Movie) model.getValueAt(i, 0)).getTitleSortable() .toLowerCase(Locale.ROOT); if (title.startsWith(searchTerm)) { ListSelectionModel selectionModel = table.getSelectionModel(); selectionModel.setSelectionInterval(i, i); table.scrollRectToVisible(new Rectangle(table.getCellRect(i, 0, true))); break; } } } } } @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyPressed(KeyEvent arg0) { } }); }
From source file:AvatarTest.java
/** * Process a keyboard event/*from w w w . j ava 2s . c o m*/ */ private void processAWTEvent(AWTEvent[] events) { for (int n = 0; n < events.length; n++) { if (events[n] instanceof KeyEvent) { KeyEvent eventKey = (KeyEvent) events[n]; if (eventKey.getID() == KeyEvent.KEY_PRESSED) { int keyCode = eventKey.getKeyCode(); int keyChar = eventKey.getKeyChar(); Vector3f translate = new Vector3f(); Transform3D t3d = new Transform3D(); m_TransformGroup.getTransform(t3d); t3d.get(translate); switch (keyCode) { case KeyEvent.VK_LEFT: translate.x += TRANSLATE_LEFT; break; case KeyEvent.VK_RIGHT: translate.x += TRANSLATE_RIGHT; break; } // System.out.println( "Steering: " + translate.x ); translate.y = 0.5f; t3d.setTranslation(translate); m_TransformGroup.setTransform(t3d); } } } }
From source file:ch.zhaw.iamp.rct.ui.GrammarWindow.java
private void grammarTextPaneKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_grammarTextPaneKeyTyped if (evt.getKeyChar() == KeyEvent.VK_TAB) { if (evt.isShiftDown()) { removeTabIfPossilbe(evt, grammarTextPane); } else {//ww w . j a va 2 s . c o m insertTabAsSpace(evt, grammarTextPane); } } }
From source file:ch.zhaw.iamp.rct.ui.GrammarWindow.java
private void initialisationTextPaneKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_initialisationTextPaneKeyTyped if (evt.getKeyChar() == KeyEvent.VK_TAB) { if (evt.isShiftDown()) { removeTabIfPossilbe(evt, initialisationTextPane); } else {/*from w w w .ja va2s. c o m*/ insertTabAsSpace(evt, initialisationTextPane); } } }
From source file:CodePointInputMethod.java
/** * This is the input method's main routine. The composed text is stored * in buffer.//from w w w .j a va 2 s. co m */ public void dispatchEvent(AWTEvent event) { // This input method handles KeyEvent only. if (!(event instanceof KeyEvent)) { return; } KeyEvent e = (KeyEvent) event; int eventID = event.getID(); boolean notInCompositionMode = buffer.length() == 0; if (eventID == KeyEvent.KEY_PRESSED) { // If we are not in composition mode, pass through if (notInCompositionMode) { return; } switch (e.getKeyCode()) { case KeyEvent.VK_LEFT: moveCaretLeft(); break; case KeyEvent.VK_RIGHT: moveCaretRight(); break; } } else if (eventID == KeyEvent.KEY_TYPED) { char c = e.getKeyChar(); // If we are not in composition mode, wait a back slash if (notInCompositionMode) { // If the type character is not a back slash, pass through if (c != '\\') { return; } startComposition(); // Enter to composition mode } else { switch (c) { case ' ': // Exit from composition mode finishComposition(); break; case '\u007f': // Delete deleteCharacter(); break; case '\b': // BackSpace deletePreviousCharacter(); break; case '\u001b': // Escape cancelComposition(); break; case '\n': // Return case '\t': // Tab sendCommittedText(); break; default: composeUnicodeEscape(c); break; } } } else { // KeyEvent.KEY_RELEASED // If we are not in composition mode, pass through if (notInCompositionMode) { return; } } e.consume(); }