List of usage examples for java.awt.event KeyEvent getKeyChar
public char getKeyChar()
From source file:MemComboBoxDemo.java
public void keyReleased(KeyEvent e) { char ch = e.getKeyChar(); if (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch)) return;// w w w .j ava2 s .com int pos = editor.getCaretPosition(); String str = editor.getText(); if (str.length() == 0) return; for (int k = 0; k < comboBox.getItemCount(); k++) { String item = comboBox.getItemAt(k).toString(); if (item.startsWith(str)) { editor.setText(item); editor.setCaretPosition(item.length()); editor.moveCaretPosition(pos); break; } } }
From source file:org.jcurl.demo.smack.ChatSimpleSwingBean.java
public ChatSimpleSwingBean() { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); text = new JTextField(); // see/*from www . j a va2s. c om*/ // http://java.sun.com/products/jfc/tsc/tech_topics/jlist_1/jlist.html: final KeyListener keyListener = new KeyAdapter() { @Override public void keyTyped(KeyEvent evt) { if ('\n' == evt.getKeyChar()) try { send(text.getText()); text.setText(""); } catch (XMPPException e) { log.error("Sending \"" + text.getText() + "\"", e); } } }; text.addKeyListener(keyListener); add(text); setEnabled(false); }
From source file:org.nekorp.workflow.desktop.view.binding.MonedaBindableJTextField.java
public MonedaBindableJTextField() { super();// ww w. j a v a 2 s . co m ignore = new LinkedList<>(); this.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent e) { char car = e.getKeyChar(); if (car != '.') { if ((car < '0' || car > '9')) { e.consume(); } } else { if (StringUtils.contains(getText(), '.')) { e.consume(); } } } @Override public void keyPressed(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { } }); }
From source file:org.jcurl.mr.exp.gui.MouseSketchPanel.java
public void keyReleased(KeyEvent e) { if (e.getKeyChar() == hotKey) { log.debug("HotKey released"); isHot = false;/*from ww w . jav a2 s .c o m*/ } }
From source file:org.jcurl.mr.gui.MouseSketchPanel.java
public void keyReleased(final KeyEvent e) { if (e.getKeyChar() == hotKey) { log.debug("HotKey released"); isHot = false;/* ww w . j a va 2s . c om*/ } }
From source file:org.jcurl.mr.exp.gui.MouseSketchPanel.java
public void keyPressed(KeyEvent e) { if (e.getKeyChar() == hotKey) { log.debug("HotKey pressed"); isHot = true;//from ww w . j a va2s . c om } switch (e.getKeyCode()) { case KeyEvent.VK_ESCAPE: this.current = null; this.curve.clear(); this.repaint(); break; case KeyEvent.VK_F1: final Graphics g = getGraphics(); paint(g, PointList.getLine(curve)); g.dispose(); break; } }
From source file:org.jcurl.mr.gui.MouseSketchPanel.java
public void keyPressed(final KeyEvent e) { if (e.getKeyChar() == hotKey) { log.debug("HotKey pressed"); isHot = true;// w w w.ja v a 2 s. c o m } switch (e.getKeyCode()) { case KeyEvent.VK_ESCAPE: current = null; curve.clear(); this.repaint(); break; case KeyEvent.VK_F1: final Graphics g = getGraphics(); paint(g, PointList.getLine(curve)); g.dispose(); break; } }
From source file:BouncingBall.java
public void keyPressed(KeyEvent e) { //Invoked when a key has been pressed. if (e.getKeyChar() == 's') { xloc = xloc + .1f;//from w ww .j a v a 2s. co m } if (e.getKeyChar() == 'a') { xloc = xloc - .1f; } }
From source file:com.sec.ose.osi.ui.frm.main.identification.common.JComboComponentName.java
private void init() { final JTextField tfComponentName = (JTextField) this.getEditor().getEditorComponent(); tfComponentName.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { char ch = e.getKeyChar(); if (ch != KeyEvent.VK_ENTER && ch != KeyEvent.VK_BACK_SPACE && ch != KeyEvent.VK_SPACE && (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch))) return; if (ch == KeyEvent.VK_ENTER) { JComboComponentName.this.hidePopup(); return; }/*from w w w.j av a 2 s. c o m*/ // 1. save string String keyword = tfComponentName.getText();//.trim(); updateComboBoxList(keyword); } }); tfComponentName.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { if (tfComponentName.getText().length() > 0) showPopup(); } public void focusLost(FocusEvent e) { hidePopup(); } }); }
From source file:SimpleInputMethod.java
public void dispatchEvent(AWTEvent event) { if (event.getID() == KeyEvent.KEY_TYPED) { KeyEvent e = (KeyEvent) event; if (handleCharacter(e.getKeyChar())) { e.consume();//from ww w .j av a2 s.co m } } }