List of usage examples for java.awt.event KeyEvent getKeyChar
public char getKeyChar()
From source file:playground.sergioo.facilitiesGenerator2012.gui.ClustersPanel.java
@Override public void keyTyped(KeyEvent e) { switch (e.getKeyChar()) { case 'v': viewAll();/*from www . j a va 2 s . com*/ break; } repaint(); }
From source file:com.haulmont.cuba.desktop.sys.vcl.DatePicker.DatePicker.java
@Override public void setEditor(final JFormattedTextField editor) { final int ENTER_CODE = 10; editor.addKeyListener(new KeyAdapter() { @Override/* www. j av a 2s. co m*/ public void keyTyped(KeyEvent e) { if (e.getKeyChar() == '\u007F' && editor.getCaretPosition() < format.length()) { editor.setCaretPosition(editor.getCaretPosition() + 1); } } @Override public void keyPressed(KeyEvent event) { if (ENTER_CODE == event.getKeyCode()) try { editor.commitEdit(); } catch (ParseException e) { // } } }); editor.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { editor.setCaretPosition(0); } }); super.setEditor(editor); if (format == null) { setFormats( Datatypes.getFormatStrings(AppBeans.get(UserSessionSource.class).getLocale()).getDateFormat()); } else setFormats(format); }
From source file:vistas.Login.java
private void txt_PassKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_PassKeyTyped char c = evt.getKeyChar(); if (c == KeyEvent.VK_ENTER) { btn_acceder.doClick();/*from w ww . j av a2s. co m*/ } }
From source file:Main.java
private void displayInfo(KeyEvent e, String keyStatus) { int id = e.getID(); String keyString;//from w ww . ja va 2 s . c o m if (id == KeyEvent.KEY_TYPED) { char c = e.getKeyChar(); keyString = "key character = '" + c + "'"; } else { int keyCode = e.getKeyCode(); keyString = "key code = " + keyCode + " (" + KeyEvent.getKeyText(keyCode) + ")"; } int modifiersEx = e.getModifiersEx(); String modString = "extended modifiers = " + modifiersEx; String tmpString = KeyEvent.getModifiersExText(modifiersEx); if (tmpString.length() > 0) { modString += " (" + tmpString + ")"; } else { modString += " (no extended modifiers)"; } String actionString = "action key? "; if (e.isActionKey()) { actionString += "YES"; } else { actionString += "NO"; } String locationString = "key location: "; int location = e.getKeyLocation(); if (location == KeyEvent.KEY_LOCATION_STANDARD) { locationString += "standard"; } else if (location == KeyEvent.KEY_LOCATION_LEFT) { locationString += "left"; } else if (location == KeyEvent.KEY_LOCATION_RIGHT) { locationString += "right"; } else if (location == KeyEvent.KEY_LOCATION_NUMPAD) { locationString += "numpad"; } else { // (location == KeyEvent.KEY_LOCATION_UNKNOWN) locationString += "unknown"; } displayArea.append(keyStatus + newline + " " + keyString + newline + " " + modString + newline + " " + actionString + newline + " " + locationString + newline); displayArea.setCaretPosition(displayArea.getDocument().getLength()); }
From source file:vistas.Login.java
private void txt_userKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_userKeyTyped char car = evt.getKeyChar(); if (txt_user.getText().length() >= 11) { evt.consume();/* w ww . j a v a2s . c om*/ } }
From source file:Main.java
private void displayInfo(KeyEvent e, String keyStatus) { int id = e.getID(); String keyString;/*from w w w.ja v a 2 s .c o m*/ if (id == KeyEvent.KEY_PRESSED) { char c = e.getKeyChar(); keyString = "key character = '" + c + "'"; } else { int keyCode = e.getKeyCode(); keyString = "key code = " + keyCode + " (" + KeyEvent.getKeyText(keyCode) + ")"; } int modifiersEx = e.getModifiersEx(); String modString = "extended modifiers = " + modifiersEx; String tmpString = KeyEvent.getModifiersExText(modifiersEx); if (tmpString.length() > 0) { modString += " (" + tmpString + ")"; } else { modString += " (no extended modifiers)"; } String actionString = "action key? "; if (e.isActionKey()) { actionString += "YES"; } else { actionString += "NO"; } String locationString = "key location: "; int location = e.getKeyLocation(); if (location == KeyEvent.KEY_LOCATION_STANDARD) { locationString += "standard"; } else if (location == KeyEvent.KEY_LOCATION_LEFT) { locationString += "left"; } else if (location == KeyEvent.KEY_LOCATION_RIGHT) { locationString += "right"; } else if (location == KeyEvent.KEY_LOCATION_NUMPAD) { locationString += "numpad"; } else { // (location == KeyEvent.KEY_LOCATION_UNKNOWN) locationString += "unknown"; } displayArea.append(keyStatus + newline + " " + keyString + newline + " " + modString + newline + " " + actionString + newline + " " + locationString + newline); displayArea.setCaretPosition(displayArea.getDocument().getLength()); }
From source file:Main.java
private void displayInfo(KeyEvent e, String keyStatus) { int id = e.getID(); String keyString;// w w w . j av a 2 s.co m if (id == KeyEvent.KEY_RELEASED) { char c = e.getKeyChar(); keyString = "key character = '" + c + "'"; } else { int keyCode = e.getKeyCode(); keyString = "key code = " + keyCode + " (" + KeyEvent.getKeyText(keyCode) + ")"; } int modifiersEx = e.getModifiersEx(); String modString = "extended modifiers = " + modifiersEx; String tmpString = KeyEvent.getModifiersExText(modifiersEx); if (tmpString.length() > 0) { modString += " (" + tmpString + ")"; } else { modString += " (no extended modifiers)"; } String actionString = "action key? "; if (e.isActionKey()) { actionString += "YES"; } else { actionString += "NO"; } String locationString = "key location: "; int location = e.getKeyLocation(); if (location == KeyEvent.KEY_LOCATION_STANDARD) { locationString += "standard"; } else if (location == KeyEvent.KEY_LOCATION_LEFT) { locationString += "left"; } else if (location == KeyEvent.KEY_LOCATION_RIGHT) { locationString += "right"; } else if (location == KeyEvent.KEY_LOCATION_NUMPAD) { locationString += "numpad"; } else { // (location == KeyEvent.KEY_LOCATION_UNKNOWN) locationString += "unknown"; } displayArea.append(keyStatus + newline + " " + keyString + newline + " " + modString + newline + " " + actionString + newline + " " + locationString + newline); displayArea.setCaretPosition(displayArea.getDocument().getLength()); }
From source file:org.slage.ui.KeyHandler.java
/** * Check if the handler should be fired, firing if needed * /* w w w . j ava 2s. c om*/ * @param keyEvt * key event * @return true if we fired */ public boolean fire(KeyEvent keyEvt) { if ((iKey == keyEvt.getKeyCode() || iKey == keyEvt.getKeyChar()) && bAlt == keyEvt.isAltDown() && bCtrl == keyEvt.isControlDown() && bShift == keyEvt.isShiftDown()) { handler.execute(); return true; } return false; }
From source file:kenh.xscript.elements.Debug.java
@Override public void keyPressed(KeyEvent e) { if (e.getKeyChar() == KeyEvent.VK_ENTER) { Object obj = e.getSource(); if (obj instanceof JTextField) { parse((JTextField) obj); }/*w ww. j ava 2 s .co m*/ } }
From source file:op.care.prescription.DlgDiscontinue.java
/** * Creates new form DlgDiscontinue//from www .j av a 2 s. co m */ private void cmbArztAbKeyPressed(KeyEvent e) { final String searchKey = String.valueOf(e.getKeyChar()); GP doc = (GP) CollectionUtils.find(listAerzte, new Predicate() { @Override public boolean evaluate(Object o) { return o != null && ((GP) o).getName().toLowerCase().charAt(0) == searchKey.toLowerCase().charAt(0); } }); if (doc != null) { cmbArztAb.setSelectedItem(doc); } }