List of usage examples for java.awt.event KeyEvent getKeyCode
public int getKeyCode()
From source file:Main.java
public KeyTextComponent() { setBackground(Color.CYAN);// ww w . j a v a2s . c o m KeyListener internalKeyListener = new KeyAdapter() { public void keyPressed(KeyEvent keyEvent) { if (actionListenerList != null) { int keyCode = keyEvent.getKeyCode(); String keyText = KeyEvent.getKeyText(keyCode); ActionEvent actionEvent = new ActionEvent(this, ActionEvent.ACTION_FIRST, keyText); fireActionPerformed(actionEvent); } } }; MouseListener internalMouseListener = new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { requestFocusInWindow(); } }; addKeyListener(internalKeyListener); addMouseListener(internalMouseListener); }
From source file:Main.java
public KeyTextComponent() { setBackground(Color.CYAN);//from www . j av a2 s. c om KeyListener internalKeyListener = new KeyAdapter() { public void keyPressed(KeyEvent keyEvent) { if (actionListenerList != null) { int keyCode = keyEvent.getKeyCode(); String keyText = KeyEvent.getKeyText(keyCode); ActionEvent actionEvent = new ActionEvent(this, ActionEvent.ACTION_FIRST, keyText, ActionEvent.ALT_MASK); fireActionPerformed(actionEvent); } } }; MouseListener internalMouseListener = new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { requestFocusInWindow(); } }; addKeyListener(internalKeyListener); addMouseListener(internalMouseListener); }
From source file:Main.java
public KeyTextComponent() { setBackground(Color.CYAN);//from w w w . j a v a 2 s . c o m KeyListener internalKeyListener = new KeyAdapter() { public void keyPressed(KeyEvent keyEvent) { if (actionListenerList != null) { int keyCode = keyEvent.getKeyCode(); String keyText = KeyEvent.getKeyText(keyCode); ActionEvent actionEvent = new ActionEvent(this, ActionEvent.ACTION_FIRST, keyText, System.currentTimeMillis() - 10, ActionEvent.ALT_MASK); fireActionPerformed(actionEvent); } } }; MouseListener internalMouseListener = new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { requestFocusInWindow(); } }; addKeyListener(internalKeyListener); addMouseListener(internalMouseListener); }
From source file:sturesy.core.ui.loaddialog.TreeListPair.java
private void registerListeners() { _fileTree.registerListener(folder -> informSourceListChanged(true)); _ui.getContentList().addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent keyEvent) { informContentListKeyEvent(keyEvent.getKeyCode()); }/*from w ww . java2s . c o m*/ }); }
From source file:com.konifar.material_icon_generator.FilterComboBox.java
private void initListener() { final JTextField textfield = (JTextField) this.getEditor().getEditorComponent(); textfield.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent event) { switch (event.getKeyCode()) { case KeyEvent.VK_ENTER: case KeyEvent.VK_ESCAPE: requestFocus(false);//from w w w . j a v a 2 s . c om break; case KeyEvent.VK_UP: case KeyEvent.VK_DOWN: break; default: SwingUtilities.invokeLater(new Runnable() { public void run() { filter(textfield.getText()); } }); } } }); getAccessibleContext().addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (AccessibleContext.ACCESSIBLE_STATE_PROPERTY.equals(event.getPropertyName()) && AccessibleState.FOCUSED.equals(event.getNewValue()) && getAccessibleContext().getAccessibleChild(0) instanceof ComboPopup) { ComboPopup popup = (ComboPopup) getAccessibleContext().getAccessibleChild(0); JList list = popup.getList(); if (list.getSelectedValue() != null) { setSelectedItem(String.valueOf(list.getSelectedValue())); } } } }); }
From source file:com.mindcognition.mindraider.ui.swing.concept.annotation.renderer.RichTextAnnotationRenderer.java
@Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_F5) { insertStringToAnnotation(new Date(System.currentTimeMillis()).toLocaleString()); }/*from www . j av a2 s .co m*/ if (e.getKeyCode() == KeyEvent.VK_F9) { insertStringToAnnotation("-----------------------------------------------------"); } if (e.getKeyCode() == KeyEvent.VK_F12) { insertStringToAnnotation("- eof -"); } genericEditorKeyListener.keyPressed(e); }
From source file:com.willwinder.universalgcodesender.uielements.components.CommandTextArea.java
private boolean isArrowKey(KeyEvent e) { switch (e.getKeyCode()) { case KeyEvent.VK_UP: case KeyEvent.VK_DOWN: return true; default:// w ww. ja v a 2 s. c o m return false; } }
From source file:org.jcodec.player.app.PlayerMain.java
public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_SPACE) { if (player.getStatus() == Player.Status.PAUSED) { if (stepper != null) { player.seek(stepper.getPos()); stepper = null;//from ww w . ja va 2 s . co m } player.play(); } else player.pause(); } else if (e.getKeyCode() == KeyEvent.VK_DOWN) { RationalLarge pos = player.getPos(); player.seek(new RationalLarge(pos.getNum() - pos.getDen() * 15, pos.getDen())); } else if (e.getKeyCode() == KeyEvent.VK_UP) { RationalLarge pos = player.getPos(); player.seek(new RationalLarge(pos.getNum() + pos.getDen() * 15, pos.getDen())); } else if (e.getKeyCode() == KeyEvent.VK_LEFT) { // if (player.getStatus() != Player.Status.PAUSED) { // player.pause(); // return; // } // // try { // if (stepper == null) { // stepper = new Stepper(video, mixer, vo, new JSoundAudioOut()); // stepper.setListeners(player.getListeners()); // stepper.gotoFrame(player.getFrameNo()); // } // stepper.prev(); // } catch (IOException e1) { // System.out.println("Couldn't step " + e1.getMessage()); // } } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) { if (player.getStatus() != Player.Status.PAUSED) { player.pause(); return; } try { if (stepper == null) { stepper = new Stepper(video, mixer, vo, new JSoundAudioOut()); stepper.setListeners(player.getListeners()); stepper.gotoFrame(player.getFrameNo()); } stepper.next(); } catch (IOException e1) { System.out.println("Couldn't step " + e1.getMessage()); } } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { player.destroy(); System.exit(-1); } else if (e.getKeyChar() >= '0' && e.getKeyChar() < '9') { int ch = e.getKeyChar() - '0'; for (Pin pin : mixer.getPins()) { if (ch < pin.getLabels().length) { pin.toggle(ch); break; } else ch -= pin.getLabels().length; } } }
From source file:com.mirth.connect.client.ui.components.KeyStrokeTextField.java
@Override public void keyTyped(KeyEvent evt) { if (keyCode != null && (evt.getKeyCode() == KeyEvent.VK_ENTER || evt.getKeyCode() == KeyEvent.VK_ESCAPE)) { return;/*from ww w .j av a 2s . c o m*/ } // Clear the text field if backspace is pressed if (evt.getKeyCode() == KeyEvent.VK_BACK_SPACE || evt.getKeyChar() == '\b') { reset(); PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } evt.consume(); }
From source file:pl.otros.logview.gui.actions.MarkAllFoundAction.java
@Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == 10 && KeyEvent.CTRL_MASK == e.getModifiers()) { actionPerformed(new ActionEvent(e.getSource(), e.getID(), "")); }// w w w . j a v a 2 s .com }