List of usage examples for java.awt.event KeyEvent getKeyCode
public int getKeyCode()
From source file:com.jcraft.weirdx.DDXWindowImp.java
public void keyReleased(KeyEvent e) { if ((window == null) || (!window.isMapped())) return;/* w ww.j a va 2 s.co m*/ Client client = window.client; if (client == null) return; int kcode = Keymap.km.getCode(e); event.mkKeyRelease(kcode, window.screen.rootId, window.id, 0, XWindow.sprite.hot.x, XWindow.sprite.hot.y, XWindow.sprite.hot.x - window.x, XWindow.sprite.hot.y - window.y, XWindow.sprite.hot.state, // state, 1); try { if (XWindow.grab != null) XWindow.sendGrabbedEvent(event, false, 1); else XWindow.sendDeviceEvent(window, event, XWindow.grab, null, 1); } catch (Exception ee) { } // change key state kcode = e.getKeyCode(); int state = XWindow.sprite.hot.state; if (kcode == KeyEvent.VK_CONTROL) { if ((state & 4) != 0) state -= 4; // check for windoze ALT_GR (is equal to ALT+CONTROL) if ((state & ALT_GR_MASK) != 0) state -= ALT_GR_MASK; } else if (kcode == KeyEvent.VK_SHIFT && !clck_toggle) { if ((state & 1) != 0) state -= 1; } else if (kcode == KeyEvent.VK_ALT) { if ((state & 8) != 0) state -= 8; } else if (kcode == VK_ALT_GRAPH) { if ((state & ALT_GR_MASK) != 0) state -= ALT_GR_MASK; } XWindow.sprite.hot.state = state; }
From source file:Report_PRCR_New_EPF_Excel_File_Generator.java
private void dayfieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_dayfieldKeyPressed /////////////////////////////////////////////////// Days Decrement///////////////////////////////////////////////////////////////////////////// if (dayfield.getText().equals("1")) { // Jumping to 31 and 30 from 1st if (evt.getKeyCode() == KeyEvent.VK_DOWN) { if (monthfield.getText().equals("Feb") || monthfield.getText().equals("Apr") || monthfield.getText().equals("Jun") || monthfield.getText().equals("Aug") || monthfield.getText().equals("Sep") || monthfield.getText().equals("Nov") || monthfield.getText().equals("Feb")) { dayfield.setText("31"); int mnth = datechooser.return_index(monthfield.getText()); monthfield.setText(datechooser.Return_month(mnth - 1)); } else if (monthfield.getText().equals("May") || monthfield.getText().equals("Jul") || monthfield.getText().equals("Oct") || monthfield.getText().equals("Dec")) { dayfield.setText("30"); int mnth = datechooser.return_index(monthfield.getText()); monthfield.setText(datechooser.Return_month(mnth - 1)); } else if (monthfield.getText().equals("Mar")) { // from march 1st jump to 28th or 29th checking leap years int yr = Integer.parseInt(yearfield.getText()); if (yr % 4 == 0) { if (yr % 100 == 0) { if (yr % 400 == 0) { dayfield.setText("29"); // Leap Year }// www. j ava 2 s . co m } if (yr % 100 == 0) { if (yr % 400 != 0) { dayfield.setText("28"); // not a leap year } } dayfield.setText("29"); // leap year } if (yr % 4 != 0) { dayfield.setText("28"); // not a leap year } int mnth = datechooser.return_index(monthfield.getText()); monthfield.setText(datechooser.Return_month(mnth - 1)); } else if (monthfield.getText().equals("Jan")) { // From jan 1st jump to december 31st decrementing year dayfield.setText("31"); int yr = Integer.parseInt(yearfield.getText()); monthfield.setText("Dec"); yearfield.setText("" + (yr - 1)); // year } dayfield.selectAll(); } // /// decrementing normal values } else if (dayfield.getText().equals("2") || dayfield.getText().equals("3") || dayfield.getText().equals("4") || dayfield.getText().equals("5") || dayfield.getText().equals("6") || dayfield.getText().equals("7") || dayfield.getText().equals("8") || dayfield.getText().equals("9") || dayfield.getText().equals("10") || dayfield.getText().equals("11") || dayfield.getText().equals("12") || dayfield.getText().equals("13") || dayfield.getText().equals("14") || dayfield.getText().equals("15") || dayfield.getText().equals("16") || dayfield.getText().equals("17") || dayfield.getText().equals("18") || dayfield.getText().equals("19") || dayfield.getText().equals("20") || dayfield.getText().equals("21") || dayfield.getText().equals("22") || dayfield.getText().equals("23") || dayfield.getText().equals("24") || dayfield.getText().equals("25") || dayfield.getText().equals("26") || dayfield.getText().equals("27") || dayfield.getText().equals("28") || dayfield.getText().equals("29") || dayfield.getText().equals("30") || dayfield.getText().equals("31")) { if (evt.getKeyCode() == KeyEvent.VK_DOWN) { dayfield.setText("" + (Integer.parseInt(dayfield.getText()) - 1)); dayfield.selectAll(); } } ///////////////////////////////////////////////// Days Increment/////////////////////////////////////////////////////////////////////////////////////////////////// if (dayfield.getText().equals("30")) { // from 30th to 1st of next month if (evt.getKeyCode() == KeyEvent.VK_UP) { if (monthfield.getText().equals("Apr") || monthfield.getText().equals("Jun") || monthfield.getText().equals("Sep") || monthfield.getText().equals("Nov")) { dayfield.setText("0"); int mnth = datechooser.return_index(monthfield.getText()); monthfield.setText(datechooser.Return_month(mnth + 1)); } dayfield.setText("" + (Integer.parseInt(dayfield.getText()) + 1)); dayfield.selectAll(); } } else if (dayfield.getText().equals("31")) { // from 31st to 1st of next month if (evt.getKeyCode() == KeyEvent.VK_UP) { if (monthfield.getText().equals("Jan") || monthfield.getText().equals("Mar") || monthfield.getText().equals("May") || monthfield.getText().equals("Jul") || monthfield.getText().equals("Aug") || monthfield.getText().equals("Oct")) { dayfield.setText("1"); int mnth = datechooser.return_index(monthfield.getText()); monthfield.setText(datechooser.Return_month(mnth + 1)); } else if (monthfield.getText().equals("Dec")) { // December to january incrementing the year dayfield.setText("1"); int yr = Integer.parseInt(yearfield.getText()); monthfield.setText("Jan"); yearfield.setText("" + (yr + 1)); } dayfield.selectAll(); } } else if (monthfield.getText().equals("Feb")) { // for february if (evt.getKeyCode() == KeyEvent.VK_UP) { if (dayfield.getText().equals("28")) { // at 28 check for leap year int yr = Integer.parseInt(yearfield.getText()); if (yr % 4 == 0) { if (yr % 100 == 0) { if (yr % 400 == 0) { dayfield.setText("29"); // Leap Year // increment to 29 } } if (yr % 100 == 0) { if (yr % 400 != 0) { dayfield.setText("1"); int mnth = datechooser.return_index(monthfield.getText()); monthfield.setText(datechooser.Return_month(mnth + 1)); // not a leap year // jump to next month } } dayfield.setText("29"); // leap year // increment to 29th } if (yr % 4 != 0) { dayfield.setText("1"); int mnth = datechooser.return_index(monthfield.getText()); monthfield.setText(datechooser.Return_month(mnth + 1)); // not a leap year } } else if (dayfield.getText().equals("29")) { // at 29 jump to next month normally dayfield.setText("1"); int mnth = datechooser.return_index(monthfield.getText()); monthfield.setText(datechooser.Return_month(mnth + 1)); // incrementing normal values/////////////////////// for february separately } else if (dayfield.getText().equals("1") || dayfield.getText().equals("2") || dayfield.getText().equals("3") || dayfield.getText().equals("4") || dayfield.getText().equals("5") || dayfield.getText().equals("6") || dayfield.getText().equals("7") || dayfield.getText().equals("8") || dayfield.getText().equals("9") || dayfield.getText().equals("10") || dayfield.getText().equals("11") || dayfield.getText().equals("12") || dayfield.getText().equals("13") || dayfield.getText().equals("14") || dayfield.getText().equals("15") || dayfield.getText().equals("16") || dayfield.getText().equals("17") || dayfield.getText().equals("18") || dayfield.getText().equals("19") || dayfield.getText().equals("20") || dayfield.getText().equals("21") || dayfield.getText().equals("22") || dayfield.getText().equals("23") || dayfield.getText().equals("24") || dayfield.getText().equals("25") || dayfield.getText().equals("26") || dayfield.getText().equals("27") || dayfield.getText().equals("28") || dayfield.getText().equals("29") || dayfield.getText().equals("30") || dayfield.getText().equals("31")) { dayfield.setText("" + (Integer.parseInt(dayfield.getText()) + 1)); } dayfield.selectAll(); } // incrementing normal values } else if (dayfield.getText().equals("1") || dayfield.getText().equals("2") || dayfield.getText().equals("3") || dayfield.getText().equals("4") || dayfield.getText().equals("5") || dayfield.getText().equals("6") || dayfield.getText().equals("7") || dayfield.getText().equals("8") || dayfield.getText().equals("9") || dayfield.getText().equals("10") || dayfield.getText().equals("11") || dayfield.getText().equals("12") || dayfield.getText().equals("13") || dayfield.getText().equals("14") || dayfield.getText().equals("15") || dayfield.getText().equals("16") || dayfield.getText().equals("17") || dayfield.getText().equals("18") || dayfield.getText().equals("19") || dayfield.getText().equals("20") || dayfield.getText().equals("21") || dayfield.getText().equals("22") || dayfield.getText().equals("23") || dayfield.getText().equals("24") || dayfield.getText().equals("25") || dayfield.getText().equals("26") || dayfield.getText().equals("27") || dayfield.getText().equals("28") || dayfield.getText().equals("29") || dayfield.getText().equals("30") || dayfield.getText().equals("31")) { if (evt.getKeyCode() == KeyEvent.VK_UP) { dayfield.setText("" + (Integer.parseInt(dayfield.getText()) + 1)); dayfield.selectAll(); } } if (evt.getKeyCode() == KeyEvent.VK_RIGHT) { monthfield.requestFocus(); monthfield.selectAll(); } if (evt.getKeyCode() == KeyEvent.VK_ENTER) { } }
From source file:ca.phon.ipamap.IpaMap.java
public void showSearchFrame(ActionEvent ae) { if (searchFrame == null) { searchFrame = new JFrame("IPA Map : Search"); searchFrame.setAlwaysOnTop(true); searchFrame.setUndecorated(true); searchFrame.getRootPane().putClientProperty("Window.shadow", Boolean.FALSE); searchField = createSearchField(); searchFrame.add(searchField);// w ww . j av a2 s . c o m searchField.getTextField().addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { searchFrame.setVisible(false); } } @Override public void keyReleased(KeyEvent e) { } @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { searchFrame.setVisible(false); } } }); searchField.getEndButton().addActionListener(evt -> { searchFrame.setVisible(false); }); searchFrame.addWindowFocusListener(new WindowFocusListener() { @Override public void windowLostFocus(WindowEvent e) { searchFrame.setVisible(false); } @Override public void windowGainedFocus(WindowEvent e) { } }); } final JComponent source = (JComponent) ae.getSource(); searchFrame.setSize(source.getWidth(), source.getHeight()); Point sourcePt = ((JComponent) ae.getSource()).getLocationOnScreen(); searchFrame.setLocation(sourcePt.x, sourcePt.y); searchFrame.setVisible(true); searchFrame.requestFocus(); searchField.getTextField().requestFocus(); }
From source file:ru.goodfil.catalog.ui.forms.CarsPanel.java
private void motorsTableKeyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_INSERT) { createMotorBtnActionPerformed(null); }/*ww w . j ava 2 s . c om*/ if (e.getKeyCode() == KeyEvent.VK_DELETE) { removeMotorBtnActionPerformed(null); } if (e.getKeyCode() == KeyEvent.VK_SPACE) { editMotorBtnActionPerformed(null); } if ((e.getKeyCode() == KeyEvent.VK_X) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) { putObjectToMyClipboard(getSelectedMotors()); this.setOperation(OPERATION_CUT); } if ((e.getKeyCode() == KeyEvent.VK_C) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) { putObjectToMyClipboard(getSelectedMotors()); this.setOperation(OPERATION_COPY); } if ((e.getKeyCode() == KeyEvent.VK_V) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) { List<Motor> motors = new ArrayList<Motor>(); motors.addAll(getFromClipboardByType(Motor.class)); if (motors.size() > 0) { Long seriaIdNew = getSelectedSeriaId(); Assert.notNull(seriaIdNew); if (getOperation() == OPERATION_COPY) { carsService.doCopyMotors(motors, seriaIdNew); } if (getOperation() == OPERATION_CUT) { carsService.doCutMotors(motors, seriaIdNew); } reReadMotors(seriaIdNew); } } }
From source file:ru.goodfil.catalog.ui.forms.CarsPanel.java
private void manufactorsListKeyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_INSERT) { createManufactorBtnActionPerformed(null); }/* w w w . ja v a 2s.co m*/ if (e.getKeyCode() == KeyEvent.VK_DELETE) { removeManufactorBtnActionPerformed(null); } if (e.getKeyCode() == KeyEvent.VK_SPACE) { editManufactorBtnActionPerformed(null); } if (e.getKeyCode() == KeyEvent.VK_ENTER) { manufactorsListValueChanged(null); } if ((e.getKeyCode() == KeyEvent.VK_X) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) { putObjectToMyClipboard(getSelectedManufactors()); this.setOperation(OPERATION_CUT); } if ((e.getKeyCode() == KeyEvent.VK_C) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) { putObjectToMyClipboard(getSelectedManufactors()); this.setOperation(OPERATION_COPY); } if ((e.getKeyCode() == KeyEvent.VK_V) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) { List<Manufactor> manufactors = new ArrayList<Manufactor>(); manufactors.addAll(getFromClipboardByType(Manufactor.class)); if (manufactors.size() > 0) { Long vechicleTypeIdNew = getSelectedVechicleTypeId(); Assert.notNull(vechicleTypeIdNew); if (getOperation() == OPERATION_COPY) { carsService.doCopyManufactors(manufactors, vechicleTypeIdNew); } if (getOperation() == OPERATION_CUT) { carsService.doCutManufactors(manufactors, vechicleTypeIdNew); } reReadManufactors(vechicleTypeIdNew); } } }
From source file:ru.goodfil.catalog.ui.forms.CarsPanel.java
private void seriesListKeyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_INSERT) { createSeriaBtnActionPerformed(null); }//from ww w. j a v a2s .co m if (e.getKeyCode() == KeyEvent.VK_DELETE) { removeSeriaBtnActionPerformed(null); } if (e.getKeyCode() == KeyEvent.VK_SPACE) { editSeriaBtnActionPerformed(null); } if (e.getKeyCode() == KeyEvent.VK_ENTER) { seriesListValueChanged(null); } if ((e.getKeyCode() == KeyEvent.VK_X) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) { putObjectToMyClipboard(getSelectedSeries()); this.setOperation(OPERATION_CUT); } if ((e.getKeyCode() == KeyEvent.VK_C) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) { putObjectToMyClipboard(getSelectedSeries()); this.setOperation(OPERATION_COPY); } if ((e.getKeyCode() == KeyEvent.VK_V) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) { List<Seria> series = new ArrayList<Seria>(); series.addAll(getFromClipboardByType(Seria.class)); if (series.size() > 0) { Long manufactorIdNew = getSelectedManufatorId(); Assert.notNull(manufactorIdNew); if (getOperation() == OPERATION_COPY) { carsService.doCopySeries(series, manufactorIdNew); } if (getOperation() == OPERATION_CUT) { carsService.doCutSeries(series, manufactorIdNew); } reReadSeries(manufactorIdNew); } } }
From source file:pl.edu.icm.visnow.geometries.viewer3d.Display3DPanel.java
private void formKeyReleased(KeyEvent evt) { switch (evt.getKeyCode()) { case CAMERA_UP_KEY: cameraUpKeyPressed = false;/*from w ww . j av a 2 s . c o m*/ processCameraKeys(evt); break; case CAMERA_DOWN_KEY: cameraDownKeyPressed = false; processCameraKeys(evt); break; case CAMERA_LEFT_KEY: cameraLeftKeyPressed = false; processCameraKeys(evt); break; case CAMERA_RIGHT_KEY: cameraRightKeyPressed = false; processCameraKeys(evt); break; case CAMERA_FORWARD_KEY: cameraForwardKeyPressed = false; processCameraKeys(evt); break; case CAMERA_BACKWARD_KEY: cameraBackwardKeyPressed = false; processCameraKeys(evt); break; case KeyEvent.VK_BACK_SPACE: reset(); break; default: break; } }
From source file:br.com.atmatech.sac.view.ViewPessoa.java
private void jTconsultaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTconsultaKeyPressed // TODO add your handling code here: if (evt.getKeyCode() == KeyEvent.VK_F12 && jTtcidade.getSelectedRow() > -1) { jTiddistrito.setText(jTtcidade.getValueAt(jTtcidade.getSelectedRow(), 0).toString()); jTcidade.setText(jTtcidade.getValueAt(jTtcidade.getSelectedRow(), 1).toString()); jDcidade.setVisible(false);//from w ww.ja v a 2 s . co m } }
From source file:br.com.atmatech.sac.view.ViewAtendimento.java
private void jTajudaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTajudaKeyPressed // TODO add your handling code here: if (evt.getKeyCode() == KeyEvent.VK_ENTER) { consultaAjuda();//from w w w. j a v a 2 s.c o m } }
From source file:br.com.atmatech.sac.view.ViewAtendimento.java
private void jTpendenteKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTpendenteKeyPressed // TODO add your handling code here: if (evt.getKeyCode() == KeyEvent.VK_TAB) { jTsolicitacao.transferFocus();//w ww . j a v a 2 s .co m } }