List of usage examples for java.awt.event KeyEvent CHAR_UNDEFINED
char CHAR_UNDEFINED
To view the source code for java.awt.event KeyEvent CHAR_UNDEFINED.
Click Source Link
From source file:net.sf.jabref.gui.AutoCompleteListener.java
@Override public void keyPressed(KeyEvent e) { if ((toSetIn != null) && (e.getKeyCode() == KeyEvent.VK_ENTER)) { JTextComponent comp = (JTextComponent) e.getSource(); // replace typed characters by characters from completion lastBeginning = lastCompletions[lastShownCompletion]; int end = comp.getSelectionEnd(); comp.select(end, end);// w ww.ja va2 s . co m toSetIn = null; if (consumeEnterKey) { e.consume(); } } // Cycle through alternative completions when user presses PGUP/PGDN: else if ((e.getKeyCode() == KeyEvent.VK_PAGE_DOWN) && (toSetIn != null)) { cycle((JTextComponent) e.getSource(), 1); e.consume(); } else if ((e.getKeyCode() == KeyEvent.VK_PAGE_UP) && (toSetIn != null)) { cycle((JTextComponent) e.getSource(), -1); e.consume(); } // else if ((e.getKeyCode() == KeyEvent.VK_BACK_SPACE)) { // StringBuffer currentword = getCurrentWord((JTextComponent) e.getSource()); // // delete last char to obey semantics of back space // currentword.deleteCharAt(currentword.length()-1); // doCompletion(currentword, e); // } else if (e.getKeyChar() == KeyEvent.CHAR_UNDEFINED) { if (e.getKeyCode() != KeyEvent.VK_SHIFT) { // shift is OK, everyhting else leads to a reset resetAutoCompletion(); } else { LOGGER.debug("Special case: shift pressed. No action."); } } else { LOGGER.debug("Special case: defined character, but not caught above"); } }
From source file:net.sf.jabref.gui.autocompleter.AutoCompleteListener.java
@Override public void keyPressed(KeyEvent e) { if ((toSetIn != null) && (e.getKeyCode() == KeyEvent.VK_ENTER)) { JTextComponent comp = (JTextComponent) e.getSource(); // replace typed characters by characters from completion lastBeginning = lastCompletions.get(lastShownCompletion); int end = comp.getSelectionEnd(); comp.select(end, end);//from w w w . ja v a 2 s . c o m toSetIn = null; if (consumeEnterKey) { e.consume(); } } // Cycle through alternative completions when user presses PGUP/PGDN: else if ((e.getKeyCode() == KeyEvent.VK_PAGE_DOWN) && (toSetIn != null)) { cycle((JTextComponent) e.getSource(), 1); e.consume(); } else if ((e.getKeyCode() == KeyEvent.VK_PAGE_UP) && (toSetIn != null)) { cycle((JTextComponent) e.getSource(), -1); e.consume(); } // else if ((e.getKeyCode() == KeyEvent.VK_BACK_SPACE)) { // StringBuffer currentword = getCurrentWord((JTextComponent) e.getSource()); // // delete last char to obey semantics of back space // currentword.deleteCharAt(currentword.length()-1); // doCompletion(currentword, e); // } else if (e.getKeyChar() == KeyEvent.CHAR_UNDEFINED) { if (e.getKeyCode() == KeyEvent.VK_SHIFT) { // shift is OK, everything else leads to a reset LOGGER.debug("Special case: shift pressed. No action."); } else { resetAutoCompletion(); } } else { LOGGER.debug("Special case: defined character, but not caught above"); } }
From source file:com.callidusrobotics.swing.SwingConsole.java
@Override @SuppressWarnings("PMD.NullAssignment") public char getKeyPress() { lastKeyPressed = null;//from w ww .j a va 2 s .c o m while (lastKeyPressed == null) { Thread.yield(); } if (lastKeyPressed.getKeyChar() == KeyEvent.CHAR_UNDEFINED) { return (char) lastKeyPressed.getKeyCode(); } return lastKeyPressed.getKeyChar(); }
From source file:brut.androlib.res.xml.ResXmlEncoders.java
private static boolean isPrintableChar(char c) { Character.UnicodeBlock block = Character.UnicodeBlock.of(c); return !Character.isISOControl(c) && c != KeyEvent.CHAR_UNDEFINED && block != null && block != Character.UnicodeBlock.SPECIALS; }
From source file:com.forerunnergames.tools.common.Strings.java
/** * Checks whether the character c is a printable character. * * @param c/* w w w .j a v a 2s . co m*/ * The character to check. * * @return True if the character c is a printable character, false otherwise. */ public static boolean isPrintable(final char c) { final Character.UnicodeBlock unicodeBlock = Character.UnicodeBlock.of(c); return !Character.isISOControl(c) && c != KeyEvent.CHAR_UNDEFINED && unicodeBlock != null && unicodeBlock != Character.UnicodeBlock.SPECIALS; }
From source file:com.callidusrobotics.swing.SwingConsole.java
@Override public String getline(final int maxLen, final Color foreground, final Color background) throws ArrayIndexOutOfBoundsException { final StringBuffer stringBuffer = new StringBuffer(maxLen); boolean keepPolling = true; while (keepPolling) { if (stringBuffer.length() < maxLen) { showCursor();//w w w. ja v a 2 s .c om } else { hideCursor(); } render(); final char input = getKeyTyped(); switch (input) { case KeyEvent.VK_ENTER: keepPolling = false; break; case KeyEvent.VK_BACK_SPACE: if (stringBuffer.length() > 0) { stringBuffer.deleteCharAt(stringBuffer.length() - 1); moveCursor(cursorRow, cursorCol - 1); print(cursorRow, cursorCol, ' ', background, background); } break; case KeyEvent.CHAR_UNDEFINED: case KeyEvent.VK_DELETE: case KeyEvent.VK_ESCAPE: // ignore these characters break; default: if (stringBuffer.length() < maxLen) { stringBuffer.append(input); print(cursorRow, cursorCol, input, foreground, background); moveCursor(cursorRow, cursorCol + 1); } } } hideCursor(); render(); return stringBuffer.toString(); }
From source file:com.AandR.beans.plotting.imagePlotPanel.CanvasPanel.java
/** * *//*w ww . j a v a 2 s. c o m*/ public void actionPerformed(ActionEvent e) { JMenuItem item = (JMenuItem) e.getSource(); int modifiers = item.getAccelerator().getModifiers(); int keyCode = item.getAccelerator().getKeyCode(); dispatchEvent(new KeyEvent(this, KeyEvent.KEY_PRESSED, 0, modifiers, keyCode, KeyEvent.CHAR_UNDEFINED)); }
From source file:com.sec.ose.osi.ui.frm.main.manage.dialog.JDlgProjectCreate.java
/** * This method initializes jComboBoxClonedFrom * /*w w w.j a v a2s . co m*/ * @return javax.swing.JComboBox */ private JComboBox<String> getJComboBoxClonedFrom() { if (jComboBoxClonedFrom == null) { jComboBoxClonedFrom = new JComboBox<String>(); jComboBoxClonedFrom.setRenderer(new ComboToopTip()); jComboBoxClonedFrom.setEditable(true); jComboBoxClonedFrom.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { log.debug("jComboBoxClonedFrom.actionPerformed()"); eventHandler.handleEvent(EventHandler.COMBO_CLONED_FROM); } }); refresh(jComboBoxClonedFrom); final JTextField editor; editor = (JTextField) jComboBoxClonedFrom.getEditor().getEditorComponent(); editor.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { char ch = e.getKeyChar(); if (ch != KeyEvent.VK_ENTER && ch != KeyEvent.VK_BACK_SPACE && (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch))) return; if (ch == KeyEvent.VK_ENTER) { jComboBoxClonedFrom.hidePopup(); return; } String str = editor.getText(); if (jComboBoxClonedFrom.getComponentCount() > 0) { jComboBoxClonedFrom.removeAllItems(); } jComboBoxClonedFrom.addItem(str); try { String tmpProjectName = null; if (str.length() > 0) { for (int i = 0; i < names.size(); i++) { tmpProjectName = names.get(i); if (tmpProjectName.toLowerCase().startsWith(str.toLowerCase())) jComboBoxClonedFrom.addItem(tmpProjectName); } } else { for (int i = 0; i < names.size(); i++) { jComboBoxClonedFrom.addItem(names.get(i)); } } } catch (Exception e1) { log.warn(e1.getMessage()); } jComboBoxClonedFrom.hidePopup(); if (str.length() > 0) jComboBoxClonedFrom.showPopup(); } }); editor.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { if (editor.getText().length() > 0) jComboBoxClonedFrom.showPopup(); } public void focusLost(FocusEvent e) { jComboBoxClonedFrom.hidePopup(); } }); } return jComboBoxClonedFrom; }
From source file:org.tinymediamanager.ui.movies.MoviePanel.java
private void addKeyListener() { table.addKeyListener(new KeyListener() { private long lastKeypress = 0; private String searchTerm = ""; @Override/*from w ww.j a v a 2 s . c om*/ public void keyTyped(KeyEvent arg0) { long now = System.currentTimeMillis(); if (now - lastKeypress > 500) { searchTerm = ""; } lastKeypress = now; if (arg0.getKeyChar() != KeyEvent.CHAR_UNDEFINED) { searchTerm += arg0.getKeyChar(); } if (StringUtils.isNotBlank(searchTerm)) { TableModel model = table.getModel(); for (int i = 0; i < model.getRowCount(); i++) { if (model.getValueAt(i, 0) instanceof Movie) { String title = ((Movie) model.getValueAt(i, 0)).getTitleSortable() .toLowerCase(Locale.ROOT); if (title.startsWith(searchTerm)) { ListSelectionModel selectionModel = table.getSelectionModel(); selectionModel.setSelectionInterval(i, i); table.scrollRectToVisible(new Rectangle(table.getCellRect(i, 0, true))); break; } } } } } @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyPressed(KeyEvent arg0) { } }); }