List of usage examples for java.awt.event KeyEvent KEY_PRESSED
int KEY_PRESSED
To view the source code for java.awt.event KeyEvent KEY_PRESSED.
Click Source Link
From source file:org.yccheok.jstock.gui.charting.InvestmentFlowLayerUI.java
@Override public void processKeyEvent(java.awt.event.KeyEvent e, JXLayer<? extends V> l) { if (e.getID() != KeyEvent.KEY_PRESSED) { // We are only interested in KEY_PRESSED event. return;//from w ww. j a v a 2 s .c o m } final int code = e.getKeyCode(); switch (code) { case KeyEvent.VK_LEFT: this.updatePointAndIndexIfPossible(-1); break; case KeyEvent.VK_RIGHT: this.updatePointAndIndexIfPossible(+1); break; case KeyEvent.VK_UP: // Switch to another stock. this.investmentFlowChartJDialog.selectPreviousJComboBoxSelection(); break; case KeyEvent.VK_DOWN: // Switch to another stock. this.investmentFlowChartJDialog.selectNextJComboBoxSelection(); break; } }
From source file:KeyNavigateTest.java
public void initialize() { WakeupCriterion[] keyEvents = new WakeupCriterion[2]; keyEvents[0] = new WakeupOnAWTEvent(KeyEvent.KEY_PRESSED); keyEvents[1] = new WakeupOnAWTEvent(KeyEvent.KEY_RELEASED); keyCriterion = new WakeupOr(keyEvents); wakeupOn(keyCriterion);//from w w w . j a v a2 s.c o m }
From source file:KeyNavigateTest.java
public void processStimulus(Enumeration criteria) { WakeupCriterion wakeup;//w w w.java 2 s . c o m AWTEvent[] event; while (criteria.hasMoreElements()) { wakeup = (WakeupCriterion) criteria.nextElement(); if (!(wakeup instanceof WakeupOnAWTEvent)) continue; event = ((WakeupOnAWTEvent) wakeup).getAWTEvent(); for (int i = 0; i < event.length; i++) { if (event[i].getID() == KeyEvent.KEY_PRESSED) { processKeyEvent((KeyEvent) event[i]); } } } wakeupOn(keyCriterion); }
From source file:com.willwinder.universalgcodesender.MainWindow.java
private void initProgram() { Localization.initialize(this.settings.getLanguage()); try {/*from ww w .j ava2 s .c o m*/ backend.applySettings(settings); } catch (Exception e) { displayErrorDialog(e.getMessage()); } this.setLocalLabels(); this.loadPortSelector(); this.checkScrollWindow(); this.loadFirmwareSelector(); this.setTitle( Localization.getString("title") + " (" + Localization.getString("version") + " " + VERSION + ")"); // Command History this.manualCommandHistory = new ArrayList<>(); // Add keyboard listener for manual controls. KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher() { @Override public boolean dispatchKeyEvent(KeyEvent e) { // Check context. if (((arrowMovementEnabled.isSelected()) && e.getID() == KeyEvent.KEY_PRESSED) && xPlusButton.isEnabled()) { switch (e.getKeyCode()) { case KeyEvent.VK_RIGHT: case KeyEvent.VK_KP_RIGHT: case KeyEvent.VK_NUMPAD6: xPlusButtonActionPerformed(null); e.consume(); return true; case KeyEvent.VK_LEFT: case KeyEvent.VK_KP_LEFT: case KeyEvent.VK_NUMPAD4: xMinusButtonActionPerformed(null); e.consume(); return true; case KeyEvent.VK_UP: case KeyEvent.VK_KP_UP: case KeyEvent.VK_NUMPAD8: yPlusButtonActionPerformed(null); e.consume(); return true; case KeyEvent.VK_DOWN: case KeyEvent.VK_KP_DOWN: case KeyEvent.VK_NUMPAD2: yMinusButtonActionPerformed(null); e.consume(); return true; case KeyEvent.VK_PAGE_UP: case KeyEvent.VK_NUMPAD9: zPlusButtonActionPerformed(null); e.consume(); return true; case KeyEvent.VK_PAGE_DOWN: case KeyEvent.VK_NUMPAD3: zMinusButtonActionPerformed(null); e.consume(); return true; case KeyEvent.VK_ADD: increaseStepActionPerformed(null); e.consume(); return true; case KeyEvent.VK_SUBTRACT: decreaseStepActionPerformed(null); e.consume(); return true; case KeyEvent.VK_DIVIDE: divideStepActionPerformed(null); e.consume(); return true; case KeyEvent.VK_MULTIPLY: multiplyStepActionPerformed(null); e.consume(); return true; case KeyEvent.VK_INSERT: case KeyEvent.VK_NUMPAD0: resetCoordinatesButtonActionPerformed(null); e.consume(); return true; default: break; } } return false; } }); }
From source file:fs.MainWindow.java
private void jButton35ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton35ActionPerformed dispatchEvent(new KeyEvent(this, KeyEvent.KEY_PRESSED, 0, 0, KeyEvent.VK_F1)); }
From source file:fs.MainWindow.java
private void jButton34ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton34ActionPerformed dispatchEvent(new KeyEvent(this, KeyEvent.KEY_PRESSED, 0, 0, KeyEvent.VK_F1)); }
From source file:fs.MainWindow.java
private void jButton33ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton33ActionPerformed dispatchEvent(new KeyEvent(this, KeyEvent.KEY_PRESSED, 0, 0, KeyEvent.VK_F1)); }
From source file:fs.MainWindow.java
private void jButton32ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton32ActionPerformed dispatchEvent(new KeyEvent(this, KeyEvent.KEY_PRESSED, 0, 0, KeyEvent.VK_F1)); }
From source file:org.eclipse.jubula.rc.swing.driver.RobotAwtImpl.java
/** * {@inheritDoc}//from w w w. j av a 2 s . c o m */ public void type(Object graphicsComponent, char character) throws RobotException { Validate.notNull(graphicsComponent, "The graphic component must not be null"); //$NON-NLS-1$ try { int modifier = 0; Component component = (Component) graphicsComponent; KeyEvent ke = new KeyEvent(component, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), modifier, KeyEvent.VK_UNDEFINED, character); Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(ke); ke = new KeyEvent(component, KeyEvent.KEY_TYPED, System.currentTimeMillis(), modifier, KeyEvent.VK_UNDEFINED, character); Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(ke); IRobotEventConfirmer confirmer = m_interceptor .intercept(new InterceptorOptions(new long[] { AWTEvent.KEY_EVENT_MASK })); ke = new KeyEvent(component, KeyEvent.KEY_RELEASED, System.currentTimeMillis(), modifier, KeyEvent.VK_UNDEFINED, character); Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(ke); confirmer.waitToConfirm(component, new DefaultAwtEventMatcher(KeyEvent.KEY_RELEASED)); } catch (AWTError awte) { log.error(awte); throw new RobotException(awte); } catch (SecurityException se) { log.error(se); throw new RobotException(se); } }
From source file:org.eclipse.jubula.rc.swing.driver.RobotAwtImpl.java
/** * Implements the key press or release. * @param graphicsComponent The component, may be <code>null</code> * @param keyCode The key code//from ww w.jav a 2 s .c o m * @param press If <code>true</code>, the key is pressed, otherwise released */ private void keyPressReleaseImpl(Object graphicsComponent, int keyCode, boolean press) { InterceptorOptions options = new InterceptorOptions(new long[] { AWTEvent.KEY_EVENT_MASK }); IRobotEventConfirmer confirmer = m_interceptor.intercept(options); if (press) { m_robot.keyPress(keyCode); m_eventFlusher.flush(); } else { m_robot.keyRelease(keyCode); m_eventFlusher.flush(); } confirmer.waitToConfirm(graphicsComponent, new KeyAwtEventMatcher(press ? KeyEvent.KEY_PRESSED : KeyEvent.KEY_RELEASED)); }