List of usage examples for java.awt.event KeyEvent isControlDown
public boolean isControlDown()
From source file:com.frostwire.gui.library.LibraryUtils.java
public static boolean isRefreshKeyEvent(KeyEvent e) { int keyCode = e.getKeyCode(); boolean ctrlCmdDown = e.isControlDown() || e.isAltGraphDown() || e.isMetaDown(); return keyCode == KeyEvent.VK_F5 || (ctrlCmdDown && keyCode == KeyEvent.VK_R); }
From source file:UndoableTextArea.java
public void keyPressed(KeyEvent e) { if ((e.getKeyCode() == KeyEvent.VK_Z) && (e.isControlDown())) { try {//from ww w. ja v a2s . co m m_undoManager.undo(); } catch (CannotUndoException cue) { Toolkit.getDefaultToolkit().beep(); } } if ((e.getKeyCode() == KeyEvent.VK_Y) && (e.isControlDown())) { try { m_undoManager.redo(); } catch (CannotRedoException cue) { Toolkit.getDefaultToolkit().beep(); } } }
From source file:org.slage.ui.KeyHandler.java
/** * Check if the handler should be fired, firing if needed * //from w w w.j av a 2s . c o m * @param keyEvt * key event * @return true if we fired */ public boolean fire(KeyEvent keyEvt) { if ((iKey == keyEvt.getKeyCode() || iKey == keyEvt.getKeyChar()) && bAlt == keyEvt.isAltDown() && bCtrl == keyEvt.isControlDown() && bShift == keyEvt.isShiftDown()) { handler.execute(); return true; } return false; }
From source file:de.pavloff.spark4knime.jsnippet.ui.JarListPanel.java
/** Inits GUI. */ public JarListPanel() { super(new BorderLayout()); m_addJarList = new JList<String>(new DefaultListModel<String>()) { /** {@inheritDoc} */ @Override//from ww w .jav a2 s . c o m protected void processComponentKeyEvent(final KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_A && e.isControlDown()) { int end = getModel().getSize() - 1; getSelectionModel().setSelectionInterval(0, end); } else if (e.getKeyCode() == KeyEvent.VK_DELETE) { onJarRemove(); } } }; m_addJarList.setCellRenderer(new ConvenientComboBoxRenderer()); add(new JScrollPane(m_addJarList), BorderLayout.CENTER); JPanel southP = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 5)); m_addJarFilesButton = new JButton("Add File(s)..."); m_addJarFilesButton.addActionListener(new ActionListener() { /** {@inheritDoc} */ @Override public void actionPerformed(final ActionEvent e) { onJarFileAdd(); } }); m_addJarURLsButton = new JButton("Add KNIME URL..."); m_addJarURLsButton.setToolTipText("Add 'knime' URLs that resolve to local paths"); m_addJarURLsButton.addActionListener(new ActionListener() { /** {@inheritDoc} */ @Override public void actionPerformed(final ActionEvent e) { onJarURLAdd(); } }); m_removeButton = new JButton("Remove"); m_removeButton.addActionListener(new ActionListener() { /** {@inheritDoc} */ @Override public void actionPerformed(final ActionEvent e) { onJarRemove(); } }); m_addJarList.addListSelectionListener(new ListSelectionListener() { /** {@inheritDoc} */ @Override public void valueChanged(final ListSelectionEvent e) { m_removeButton.setEnabled(!m_addJarList.isSelectionEmpty()); } }); m_removeButton.setEnabled(!m_addJarList.isSelectionEmpty()); southP.add(m_addJarFilesButton); southP.add(m_addJarURLsButton); southP.add(m_removeButton); add(southP, BorderLayout.SOUTH); JPanel northP = new JPanel(new FlowLayout()); JLabel label = new JLabel("<html><body>Specify additional jar files " + "that are necessary for the snippet to run</body></html>"); northP.add(label); add(northP, BorderLayout.NORTH); }
From source file:latexstudio.editor.EditorTopComponent.java
private void rSyntaxTextAreaKeyTyped(java.awt.event.KeyEvent evt) { if (currentFile == null || evt.isControlDown()) { return;/* w w w .j av a2 s . c om*/ } setDisplayName(currentFile.getName() + '*'); }
From source file:is.iclt.jcorpald.CorpaldView.java
public void keyPressed(KeyEvent event) { if (event.getKeyCode() == java.awt.event.KeyEvent.VK_S) { if (event.isControlDown()) { this.doSave(); }// w w w .j av a 2 s.co m } }
From source file:idontwant2see.IDontWant2See.java
public void eventDispatched(final AWTEvent event) { if (event instanceof KeyEvent) { final KeyEvent keyEvent = (KeyEvent) event; mCtrlPressed = keyEvent.isControlDown(); // System.out.println("Ctrl " + mCtrlPressed); }/*from w ww.j av a 2 s. co m*/ }
From source file:org.squidy.designer.zoom.impl.SourceCodeShape.java
private JEditorPane createCodePane(URL sourceCodeURL) { codePane = new JEditorPane() { @Override//w ww . j a v a2 s . c om protected void processComponentKeyEvent(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_SPACE && e.isControlDown()) { System.out.println("Code completion"); int caretPosition = codePane.getCaretPosition(); String code = codePane.getText(); switch (code.charAt(caretPosition - 1)) { case '.': int pseudoCaret = caretPosition - 1; StringBuilder word = new StringBuilder(); for (char c = code.charAt(--pseudoCaret); !isEndOfWord(c); c = code.charAt(--pseudoCaret)) { word.append(c); } word = word.reverse(); System.out.println("WORD: " + word); // Class<?> type = // ReflectionUtil.loadClass(word.toString()); // // System.out.println("TYPE: " + type); JPopupMenu menu = new JPopupMenu("sdaf"); Point p = codePane.getCaret().getMagicCaretPosition(); System.out.println("CARET POS: " + p); // Point p = codePane.get // menu.setPreferredSize(new Dimension(200, 200)); menu.setLocation(30, 30); menu.add("test"); codePane.add(menu); // System.out.println(p); // codePane.get menu.show(codePane, p.x, p.y); break; } } super.processComponentKeyEvent(e); } /** * @param c * @return */ private boolean isEndOfWord(char c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t'; } }; EditorKit editorKit = new StyledEditorKit() { /** * */ private static final long serialVersionUID = 7024886168909204806L; public Document createDefaultDocument() { return new SyntaxDocument(); } }; codePane.setEditorKitForContentType("text/java", editorKit); codePane.setContentType("text/java"); try { FileInputStream fis = new FileInputStream(sourceCodeURL.getPath()); codePane.read(fis, null); originSourceCode = codePane.getText(); computeHeightOfCodePane(); codePane.setAutoscrolls(true); } catch (Exception e) { codePane.setText("File not found!"); } codePane.requestFocus(); codePane.setBorder(BorderFactory.createLineBorder(Color.BLACK)); codePane.addKeyListener(new KeyAdapter() { /* * (non-Javadoc) * * @see * java.awt.event.KeyAdapter#keyPressed(java.awt.event.KeyEvent) */ @Override public void keyPressed(KeyEvent e) { super.keyPressed(e); switch (e.getKeyCode()) { case KeyEvent.VK_ENTER: case KeyEvent.VK_DELETE: case KeyEvent.VK_BACK_SPACE: case KeyEvent.VK_SPACE: computeHeightOfCodePane(); break; } markDirty(); } }); // final JPopupMenu menu = new JPopupMenu(); // // JMenuItem i = new JMenuItem("Option 1"); // JMenuItem i2 = new JMenuItem("Option 2"); // menu.add(i); // menu.add(i2); // edit.add(menu); // getComponent().addKeyListener(new KeyAdapter() { // // public void keyTyped(KeyEvent e) { // if(e.getModifiers() == 2 && e.getKeyChar() == ' ') { // Point popupLoc = edit.getCaret().getMagicCaretPosition(); // System.out.println(popupLoc); // menu.setLocation(new // Point((int)popupLoc.getX(),(int)popupLoc.getY())); // menu.setVisible(true); // } // // } // }); return codePane; }
From source file:client.InterfaceJeu.java
private void formKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_formKeyPressed if (evt.isControlDown() && evt.getKeyChar() == 'C') { txtFieldChatEcr.grabFocus();//from ww w . j a va 2s . c om txtFieldChatEcr.requestFocus(); System.out.println("keypress"); } }
From source file:com.dbschools.quickquiz.client.giver.MainWindow.java
private void addListeners() { takerTableDisplay.addTableKeyListener(new KeyAdapter() { @Override//from www .j av a 2 s .c om public void keyPressed(KeyEvent e) { char keyChar = e.getKeyChar(); if (Character.isDigit(keyChar) && e.isControlDown()) { awardPoints(Integer.parseInt(Character.toString(keyChar))); } } }); final ListSelectionModel takerTableSelectionModel = takerTableDisplay.getSelectionModel(); takerTableSelectionModel.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { btnAwardPoints.setEnabled(!takerTableSelectionModel.isSelectionEmpty()); } }); countdownMeter.addCountdownFinishListener(new CountdownFinishListener() { public void countdownFinished() { SwingUtilities.invokeLater(new Runnable() { public void run() { btnSendQuestion.setEnabled(true); } }); } }); }