List of usage examples for java.awt.event KeyEvent isControlDown
public boolean isControlDown()
From source file:tax.MainForm.java
private void dateTextKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_dateTextKeyPressed if (evt.getKeyCode() == KeyEvent.VK_ENTER) { if (!dateText.getText().equals("")) { Util.fadeInAndOut(dateText, Util.darkGreen); priceText.setEnabled(true);/* ww w.j a va 2 s. c o m*/ priceText.requestFocus(); } else Util.fadeInAndOut(dateText, Util.darkOrange); } else if (!evt.isActionKey() && !evt.isAltDown() && !evt.isControlDown() && !evt.isShiftDown() && !evt.isMetaDown() && (evt.getKeyCode() != KeyEvent.VK_BACK_SPACE) && (evt.getKeyCode() != KeyEvent.VK_DELETE) && (evt.getKeyCode() != KeyEvent.VK_ESCAPE)) { EventQueue.invokeLater(new Runnable() { @Override public void run() { String text = dateText.getText(); int dateLength = text.length(); while (lastDateTextLength == dateLength) { try { Thread.sleep(100); System.out.println("text: " + text); System.out.println(lastDateTextLength + " " + dateLength); return; } catch (InterruptedException ex) { Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex); } text = dateText.getText(); dateLength = text.length(); } try { int num = Integer.decode(text); if (num > 31) { if (text.length() > 0) dateText.setText(text.substring(0, dateLength - 1)); else dateText.setText(""); return; } } catch (Exception e) { if (text.length() > 0) dateText.setText(text.substring(0, dateLength - 1)); else dateText.setText(""); return; } lastDateTextLength = dateLength; } }); } }
From source file:KeyNavigateTest.java
protected void processKeyEvent(KeyEvent event) { int keycode = event.getKeyCode(); if (event.isShiftDown()) speed = FAST_SPEED;/* w w w .j a v a 2 s . co m*/ else speed = NORMAL_SPEED; if (event.isAltDown()) altMove(keycode); else if (event.isControlDown()) controlMove(keycode); else standardMove(keycode); }
From source file:tax.MainForm.java
private void afmTextSKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_afmTextSKeyPressed if (evt.getKeyCode() == KeyEvent.VK_ENTER) { String text = afmTextS.getText(); if (text.length() == 9) { try { int num = Integer.parseInt(text); } catch (Exception e) { afmTextS.setText(""); return; }//from ww w .j a va2 s. c o m // Util.fadeInAndOut(afmTextS, Util.darkGreen); addNameBut.doClick(); } else { Util.fadeInAndOut(afmTextS, Util.darkOrange); } } else if (!evt.isActionKey() && !evt.isAltDown() && !evt.isControlDown() && !evt.isShiftDown() && !evt.isMetaDown() && (evt.getKeyCode() != KeyEvent.VK_BACK_SPACE) && (evt.getKeyCode() != KeyEvent.VK_DELETE) && (evt.getKeyCode() != KeyEvent.VK_ESCAPE)) { EventQueue.invokeLater(new Runnable() { @Override public void run() { String text = afmTextS.getText(); int afmLength = text.length(); while (lastAFMTextSLength == afmLength) { try { Thread.sleep(100); System.out.println("text: " + text); System.out.println(lastAFMTextSLength + " " + afmLength); return; } catch (InterruptedException ex) { Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex); } text = afmTextS.getText(); afmLength = text.length(); } try { int num = Integer.decode(text); if (afmLength > 9) { if (text.length() > 0) afmTextS.setText(text.substring(0, afmLength - 1)); else afmTextS.setText(""); return; } } catch (Exception e) { if (text.length() > 0) afmTextS.setText(text.substring(0, afmLength - 1)); else afmTextS.setText(""); return; } lastAFMTextSLength = afmLength; } }); } }
From source file:br.com.atmatech.sac.view.ViewAtendimento.java
private void jDclienteKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jDclienteKeyPressed // TODO add your handling code here: if ((evt.getKeyCode() == KeyEvent.VK_F)) { if (evt.isControlDown()) { atalhoBuscaCliente();// www .j av a 2 s . co m } } }
From source file:br.com.atmatech.sac.view.ViewAtendimento.java
private void jTtdclienteKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTtdclienteKeyPressed // TODO add your handling code here: if ((evt.getKeyCode() == KeyEvent.VK_F)) { if (evt.isControlDown()) { atalhoBuscaCliente();// w w w . j av a 2 s .c om } } if (evt.getKeyCode() == KeyEvent.VK_ENTER) { clienteSelecionado(); } }
From source file:br.com.atmatech.sac.view.ViewPessoa.java
private void jTtempresaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTtempresaKeyPressed // TODO add your handling code here: int coluna = jTtempresa.getSelectedColumn(); if ((evt.getKeyCode() == KeyEvent.VK_F) && (coluna >= 0)) { if (evt.isControlDown()) { String text = JOptionPane.showInputDialog(this, "Pesquisa: " + jTtempresa.getColumnName(coluna), "PESQUISA", JOptionPane.WARNING_MESSAGE); if (text != null) { //DefaultTableModel tabela = (DefaultTableModel) jTtmodulo.getModel(); //final TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(tabela); // jTtmodulo.setRowSorter(sorter); text = text.toUpperCase(); if (jTtempresa.getColumnName(coluna).equals("RAZAO")) { buscaPessoa("RAZAO", text); }//from w ww . j av a2 s.c o m if (jTtempresa.getColumnName(coluna).equals("FANTASIA")) { buscaPessoa("FANTASIA", text); } if (jTtempresa.getColumnName(coluna).equals("CNPJ")) { buscaPessoa("CNPJ", text); } if (jTtempresa.getColumnName(coluna).equals("ENDERECO")) { buscaPessoa("ENDERECO", text); } } } } }
From source file:tax.MainForm.java
private void afmTextKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_afmTextKeyPressed String text = afmText.getText(); if (evt.getKeyCode() == KeyEvent.VK_ENTER) { if (text.length() == 9) { for (Object key : afmToName.keySet()) { if (afmToName.get(key).equals(text)) nameText.setText(key.toString()); }/*from w ww. ja va 2 s. com*/ // Util.fadeInAndOut(afmText, Util.darkGreen); addRowBut.doClick(); } else if (text.length() == 0) { Util.fadeInAndOut(afmText, Color.white); nameText.setEnabled(true); nameText.requestFocus(); } else Util.fadeInAndOut(afmText, Util.darkOrange); } else if (!evt.isActionKey() && !evt.isAltDown() && !evt.isControlDown() && !evt.isShiftDown() && !evt.isMetaDown() && (evt.getKeyCode() != KeyEvent.VK_BACK_SPACE) && (evt.getKeyCode() != KeyEvent.VK_DELETE) && (evt.getKeyCode() != KeyEvent.VK_ESCAPE)) { EventQueue.invokeLater(new Runnable() { @Override public void run() { String text = afmText.getText(); int afmLength = text.length(); while (lastAFMTextLength == afmLength) { try { Thread.sleep(100); System.out.println("text: " + text); System.out.println(lastAFMTextLength + " " + afmLength); return; } catch (InterruptedException ex) { Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex); } text = afmText.getText(); afmLength = text.length(); } try { int num = Integer.decode(text); if (afmLength > 9) { if (text.length() > 0) afmText.setText(text.substring(0, afmLength - 1)); else afmText.setText(""); return; } } catch (Exception e) { if (text.length() > 0) afmText.setText(text.substring(0, afmLength - 1)); else afmText.setText(""); return; } lastAFMTextLength = afmLength; } }); } }
From source file:haven.GameUI.java
public boolean globtype(char key, KeyEvent ev) { if (key == ':') { entercmd();/*w ww .j av a 2 s . co m*/ return (true); } else if (key == ' ') { toggleui(); return (true); } else if (key == 3) { if (chat.visible && !chat.hasfocus) { setfocus(chat); } else { if (chat.sz.y == 0) { chat.resize(chat.savedw, chat.savedh); setfocus(chat); } else { chat.resize(0, 0); } } Utils.setprefb("chatvis", chat.sz.y != 0); } else if (key == 16) { /* if((polity != null) && polity.show(!polity.visible)) { polity.raise(); fitwdg(polity); setfocus(polity); } */ return (true); } else if ((key == 27) && (map != null) && !map.hasfocus) { setfocus(map); return (true); } else if (key != 0) { boolean alt = ev.isAltDown(); boolean ctrl = ev.isControlDown(); boolean shift = ev.isShiftDown(); int keycode = ev.getKeyCode(); if (alt && keycode >= KeyEvent.VK_0 && keycode <= KeyEvent.VK_9) { beltwdg.setCurrentBelt(Utils.floormod(keycode - KeyEvent.VK_0 - 1, 10)); return true; } else if (alt && keycode == KeyEvent.VK_S) { studywnd.show(!studywnd.visible); if (studywnd.visible) studywnd.raise(); return true; } else if (alt && keycode == KeyEvent.VK_M) { if (mmapwnd != null) { mmapwnd.togglefold(); return true; } } else if (alt && keycode == KeyEvent.VK_C) { craftwnd.show(!craftwnd.visible); if (craftwnd.visible) craftwnd.raise(); return true; } else if (alt && keycode == KeyEvent.VK_B) { buildwnd.toggle(); if (buildwnd.visible) buildwnd.raise(); return true; } else if (alt && keycode == KeyEvent.VK_N) { Config.nightvision.set(!Config.nightvision.get()); } else if (alt && keycode == KeyEvent.VK_G) { if (map != null) map.gridOverlay.setVisible(!map.gridOverlay.isVisible()); return true; } else if (alt && keycode == KeyEvent.VK_R) { if (mmap != null) mmap.toggleCustomIcons(); return true; } else if (alt && keycode == KeyEvent.VK_D) { if (map != null) map.toggleGobRadius(); return true; } else if (alt && keycode == KeyEvent.VK_Q) { Config.showQuality.set(!Config.showQuality.get()); return true; } else if (alt && keycode == KeyEvent.VK_K) { deckwnd.show(!deckwnd.visible); deckwnd.c = new Coord(sz.sub(deckwnd.sz).div(2)); if (deckwnd.visible) deckwnd.raise(); return true; } else if (alt && keycode == KeyEvent.VK_F) { if (map != null) { map.toggleFriendlyFire(); msg("Friendly fire prevention is now turned " + (map.isPreventFriendlyFireEnabled() ? "on" : "off")); } return true; } else if (alt && keycode == KeyEvent.VK_I) { Config.showGobInfo.set(!Config.showGobInfo.get()); return true; } else if (alt && keycode == KeyEvent.VK_W) { Config.screenshotMode = !Config.screenshotMode; return true; } else if (alt && keycode == KeyEvent.VK_T) { Config.disableTileTransitions.set(!Config.disableTileTransitions.get()); ui.sess.glob.map.rebuild(); return true; } else if (keycode == KeyEvent.VK_Q && ev.getModifiers() == 0) { /* // get all forageables from config List<String> names = new ArrayList<String>(); for (CustomIconGroup group : ui.sess.glob.icons.config.groups) { if ("Forageables".equals(group.name)) { for (CustomIconMatch match : group.matches) if (match.show) names.add(match.value); break; } } tasks.add(new Forager(11 * Config.autopickRadius.get(), 1, names.toArray(new String[names.size()]))); */ ContextTaskFinder.checkForageables(tasks, ui); return true; } else if (keycode == KeyEvent.VK_E && ev.getModifiers() == 0) { ContextTaskFinder.findHandTask(tasks, ui); return true; } else if (keycode == KeyEvent.VK_F && ev.getModifiers() == 0) { ContextTaskFinder.findBuilding(tasks, ui); return true; } else if (keycode >= KeyEvent.VK_NUMPAD1 && keycode <= KeyEvent.VK_NUMPAD4) { tasks.add(new MileStoneTask(Utils.floormod(keycode - KeyEvent.VK_NUMPAD0 - 1, 10))); return true; } else if (keycode == KeyEvent.VK_W && ev.getModifiers() == 0) { tasks.add(new Drunkard()); return true; } else if (shift && keycode == KeyEvent.VK_I) { Config.hideKinInfoForNonPlayers.set(!Config.hideKinInfoForNonPlayers.get()); return true; } else if (ctrl && keycode == KeyEvent.VK_H) { Config.hideModeEnabled.set(!Config.hideModeEnabled.get()); return true; } else if (alt && keycode == KeyEvent.VK_P) { Config.showGobPaths.set(!Config.showGobPaths.get()); return true; } else if (shift && keycode == KeyEvent.VK_W) { if (Config.showQualityMode.get() == 1) { Config.showQualityMode.set(2); } else { Config.showQualityMode.set(1); } return true; } else if (keycode == KeyEvent.VK_TAB && Config.agroclosest.get()) { if (map != null) map.aggroclosest(); return true; } else if (ctrl && keycode == KeyEvent.VK_F) { Config.displayFPS.set(!Config.displayFPS.get()); return true; } else if (keycode == KeyEvent.VK_Z && ev.getModifiers() == 0) { tasks.killAllTasks(); return true; } else if (keycode == 192 && ev.getModifiers() == 0) { getparent(GameUI.class).menu.wdgmsg("act", "travel", "hearth"); return true; } else if (shift && keycode == KeyEvent.VK_S) { HavenPanel.screenshot = true; return true; } } return (super.globtype(key, ev)); }
From source file:ucar.unidata.idv.flythrough.Flythrough.java
/** * _more_// w ww .j a v a2 s.c o m * * @return _more_ */ public JComponent doMakePointsPanel() { pointTableModel = new FlythroughTableModel(this); pointTable = new JTable(pointTableModel); pointTable.setToolTipText("Double click: view; Control-P: Show point properties; Delete: delete point"); pointTable.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if ((e.getKeyCode() == KeyEvent.VK_P) && e.isControlDown()) { List<FlythroughPoint> newPoints = new ArrayList<FlythroughPoint>(); int[] rows = pointTable.getSelectedRows(); List<FlythroughPoint> oldPoints = pointsToUse; for (int j = 0; j < rows.length; j++) { FlythroughPoint pt = oldPoints.get(rows[j]); if (!showProperties(pt)) { break; } pointTable.repaint(); } } if (GuiUtils.isDeleteEvent(e)) { List<FlythroughPoint> newPoints = new ArrayList<FlythroughPoint>(); int[] rows = pointTable.getSelectedRows(); List<FlythroughPoint> oldPoints = pointsToUse; for (int i = 0; i < oldPoints.size(); i++) { boolean good = true; for (int j = 0; j < rows.length; j++) { if (i == rows[j]) { good = false; break; } } if (good) { newPoints.add(oldPoints.get(i)); } } flythrough(newPoints); } } }); pointTable.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { final int row = pointTable.rowAtPoint(e.getPoint()); if ((row < 0) || (row >= pointsToUse.size())) { return; } if (e.getClickCount() > 1) { animation.setCurrent(row); } } }); JScrollPane scrollPane = new JScrollPane(pointTable); scrollPane.setPreferredSize(new Dimension(400, 300)); return scrollPane; }
From source file:com.hexidec.ekit.EkitCore.java
public void keyPressed(KeyEvent ke) { // log.debug("> keyPressed"); int keyCode = ke.getKeyCode(); if (ke.getKeyChar() == KeyEvent.VK_ENTER && (enterIsBreak || inlineEdit)) { ke.consume();/*from ww w . j a v a 2s . com*/ } else if (keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_KP_UP) { Element tdElement = DocumentUtil.getElementByTag(htmlDoc, jtpMain.getCaretPosition(), Tag.TD); if (tdElement != null) { moveCaretOnTable(tdElement, true, ke.isShiftDown()); ke.consume(); } } else if (keyCode == KeyEvent.VK_DOWN || keyCode == KeyEvent.VK_KP_DOWN) { Element tdElement = DocumentUtil.getElementByTag(htmlDoc, jtpMain.getCaretPosition(), Tag.TD); if (tdElement != null) { moveCaretOnTable(tdElement, false, ke.isShiftDown()); ke.consume(); } } else if (keyCode == KeyEvent.VK_ENTER) { Element tdElement = DocumentUtil.getElementByTag(htmlDoc, jtpMain.getCaretPosition(), Tag.TD); // inside table if (tdElement != null) { try { insertBreakInsideTD(tdElement); } catch (Exception e) { log.error("Falha ao inserir quebra de linha.", e); } ke.consume(); } } else if (keyCode == KeyEvent.VK_D && ke.isShiftDown() && ke.isControlDown()) { debug(); } // log.debug("< keyPressed"); }