List of usage examples for java.awt.event KeyEvent getKeyCode
public int getKeyCode()
From source file:PassiveTextField.java
public void processComponentKeyEvent(KeyEvent evt) { switch (evt.getID()) { case KeyEvent.KEY_PRESSED: case KeyEvent.KEY_RELEASED: if (evt.getKeyCode() == KeyEvent.VK_ENTER) { return; }// w w w . j a v a2 s . co m break; case KeyEvent.KEY_TYPED: if (evt.getKeyChar() == '\r') { return; } break; } super.processComponentKeyEvent(evt); }
From source file:com.mirth.connect.client.ui.components.KeyStrokeTextField.java
@Override public void keyPressed(KeyEvent evt) { if (keyCode != null && (evt.getKeyCode() == KeyEvent.VK_ENTER || evt.getKeyCode() == KeyEvent.VK_ESCAPE)) { return;/*from ww w . j av a2s . c o m*/ } if (keyCode == null && evt.getKeyCode() > 0 && !ArrayUtils.contains(ignoreKeyCodes, evt.getKeyCode())) { int index = ArrayUtils.indexOf(modifierKeyCodes, evt.getKeyCode()); if (index >= 0) { modifiers |= modifierMasks[index]; } else { keyCode = evt.getKeyCode(); } updateKeyStroke(); PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } evt.consume(); }
From source file:com.mirth.connect.client.ui.components.KeyStrokeTextField.java
@Override public void keyReleased(KeyEvent evt) { if (keyCode != null && (evt.getKeyCode() == KeyEvent.VK_ENTER || evt.getKeyCode() == KeyEvent.VK_ESCAPE)) { return;//from w w w. j a va 2 s . c om } if (keyCode == null && evt.getKeyCode() > 0 && modifiers > 0 && !ArrayUtils.contains(ignoreKeyCodes, evt.getKeyCode())) { int index = ArrayUtils.indexOf(modifierKeyCodes, evt.getKeyCode()); if (index >= 0 && keyCode == null) { modifiers = (modifiers ^= modifierMasks[index]) & modifiers; } else { keyCode = evt.getKeyCode(); } updateKeyStroke(); PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } evt.consume(); }
From source file:vincent.DynamicDataDemo.java
/** * Constructs a new demonstration application. * /* w ww .j av a 2 s. c o m*/ * @param title the frame title. */ public DynamicDataDemo(final String title) { super(title); this.series = new TimeSeries("Random Data"); final TimeSeriesCollection dataset = new TimeSeriesCollection(this.series); final JFreeChart chart = createChart(dataset); final ChartPanel chartPanel = new ChartPanel(chart); final JPanel content = new JPanel(new BorderLayout()); content.add(chartPanel); chartPanel.setPreferredSize(new java.awt.Dimension(500, 300)); setContentPane(content); // Zone de saisie de commande vers le port srie : TextField zoneSaisie = new TextField(10); chartPanel.add(zoneSaisie); zoneSaisie.setLocation(100, 300); zoneSaisie.validate(); zoneSaisie.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { int key = e.getKeyCode(); if (key == KeyEvent.VK_ENTER) { TextField textField = (TextField) e.getComponent(); try { BufferedWriter writer = tempSerialReader.getEcrivainPortSerie(); writer.write(textField.getText()); writer.write('\r'); writer.flush(); } catch (IOException l_ex) { LOG.error("erreur d'criture sur le port srie: ", l_ex); } } } }); temperatureCouranteLabel = new Label("XX.XC"); chartPanel.add(temperatureCouranteLabel); chartPanel.add(tempsDeChauffeEtRelicat); chartPanel.add(paramsPid); tempSerialReader = new TempSerialReader(this); }
From source file:net.sf.maltcms.chromaui.charts.events.DomainMarkerKeyListener.java
@Override public void keyTyped(KeyEvent e) { double oldPos = xyp.getDomainCrosshairValue(); if (e.getKeyCode() == KeyEvent.VK_RIGHT) { xyp.setDomainCrosshairValue(oldPos++); // xyp.getDataset().get // final IEvent<XYItemEntity> v = new XYItemEntityClickedEvent(); // fireEvent(v); }//w w w . j a v a2s. co m if (e.getKeyCode() == KeyEvent.VK_LEFT) { xyp.setDomainCrosshairValue(oldPos--); } }
From source file:com.cburch.draw.tools.LineTool.java
@Override public void keyPressed(Canvas canvas, KeyEvent e) { int code = e.getKeyCode(); if (active && (code == KeyEvent.VK_SHIFT || code == KeyEvent.VK_CONTROL)) { updateMouse(canvas, lastMouseX, lastMouseY, e.getModifiersEx()); }/* www .j a v a 2 s. co m*/ }
From source file:org.OpenNI.Samples.UserTracker.UserTrackerApplication.java
public UserTrackerApplication(JFrame frame) { this.frame = frame; frame.addKeyListener(new KeyListener() { public void keyTyped(KeyEvent arg0) { }//w w w. j a v a 2 s . c om public void keyReleased(KeyEvent arg0) { } public void keyPressed(KeyEvent arg0) { if (arg0.getKeyCode() == KeyEvent.VK_ESCAPE) { shouldRun = false; } } }); }
From source file:CopyAreaPerformance.java
/** * Arrow keys scroll the view around. The 'c' key toggles clip area * optimization. The 'a' key toggles copyArea optimization. *//*from w w w . ja v a 2s. c o m*/ public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_RIGHT) { scroll(SCROLL_SIZE, 0); } else if (e.getKeyCode() == KeyEvent.VK_LEFT) { scroll(-SCROLL_SIZE, 0); } else if (e.getKeyCode() == KeyEvent.VK_UP) { scroll(0, -SCROLL_SIZE); } else if (e.getKeyCode() == KeyEvent.VK_DOWN) { scroll(0, SCROLL_SIZE); } else if (e.getKeyCode() == KeyEvent.VK_C) { useClip = !useClip; System.out.println("useClip = " + useClip); } else if (e.getKeyCode() == KeyEvent.VK_A) { useCopyArea = !useCopyArea; prevVX = -10000; System.out.println("useCopyArea = " + useCopyArea); } }
From source file:ImageSorter.java
/** * @param in/*from w w w . j av a 2 s. com*/ * @param leftOut * @param rightOut */ public ImageSorter(String in, String leftOut, String rightOut) { super("ImageSorter"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); inputs = new File(in).listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { String s = name.toLowerCase(); return s.endsWith("jpg"); } }); leftOutput = new File(in, leftOut); rightOutput = new File(in, rightOut); leftOutput.mkdirs(); rightOutput.mkdirs(); assert leftOutput.canWrite(); assert rightOutput.canWrite(); panel.setPreferredSize(new Dimension(640, 480)); getContentPane().setLayout(new BorderLayout()); getContentPane().add(panel, BorderLayout.CENTER); panel.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_RIGHT) { inputs[index].renameTo(new File(rightOutput, inputs[index].getName())); } else if (e.getKeyCode() == KeyEvent.VK_LEFT) { inputs[index].renameTo(new File(leftOutput, inputs[index].getName())); } nextImage(); } }); panel.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { panel.requestFocusInWindow(); } @Override public void mousePressed(MouseEvent e) { panel.requestFocusInWindow(); } @Override public void mouseEntered(MouseEvent e) { panel.requestFocusInWindow(); } @Override public void mouseClicked(MouseEvent e) { panel.requestFocusInWindow(); } }); panel.requestFocusInWindow(); nextImage(); pack(); setVisible(true); }
From source file:ve.zoonosis.controller.seguridad.LoginController.java
private void iniciarSesion(KeyEvent evt) { if (evt.getKeyCode() == KeyEvent.VK_ENTER) { evt.consume();//from w w w.java2 s . c o m iniciarSesion(); } }