List of usage examples for java.awt.event KeyEvent VK_ENTER
int VK_ENTER
To view the source code for java.awt.event KeyEvent VK_ENTER.
Click Source Link
From source file:com.emental.mindraider.ui.dialogs.DownloadModelJDialog.java
/** * Constructor.// w ww. j a v a 2 s. co m * * @param union * made union of models. */ public DownloadModelJDialog(boolean union) { super(Messages.getString("DownloadModelJDialog.title")); JPanel p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.CENTER, 1, 5)); p.add(new JLabel(Messages.getString("DownloadModelJDialog.url"))); String[] knowUris = new String[] { "http://", "http://wymiwyg.org/", "http://www.osar.ch", "http://wymiwyg.org/.rdf?appendLang=en&till=50", "http://www.osar.ch/.rdf?appendLang=de&till=50" }; modelUrlCombo = new JComboBox(knowUris); modelUrlCombo.setEditable(true); modelUrlCombo.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent keyEvent) { if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) { upload(); } } public void keyReleased(KeyEvent keyEvent) { } public void keyTyped(KeyEvent keyEvent) { } }); p.add(modelUrlCombo); JButton uploadButton = new JButton(Messages.getString("DownloadModelJDialog.download")); uploadButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { upload(); } }); p.add(uploadButton); JButton cancelButton = new JButton(Messages.getString("DownloadModelJDialog.cancel")); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dispose(); } }); p.add(cancelButton); getContentPane().add(p, BorderLayout.CENTER); // show pack(); Gfx.centerAndShowWindow(this); }
From source file:uk.co.markfrimston.tasktree.Main.java
public Main(TaskTree taskTree) { super();/*w w w . j a v a 2s . c o m*/ this.taskTree = taskTree; this.setTitle("Task Tree"); this.setSize(new Dimension(300, 500)); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel quickInPanel = new JPanel(new BorderLayout()); this.quickIn = new JTextArea(); this.quickIn.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent arg0) { if (arg0.getKeyCode() == KeyEvent.VK_ENTER) { String newText = quickIn.getText().trim(); if (newText != null && newText.length() > 0) { addTask(Main.this.taskTree.getRoot(), 0, newText, true); try { Main.this.taskTree.changesMade(); } catch (Exception e) { error(e.getMessage()); } } quickIn.setText(""); } } }); this.quickIn.setPreferredSize(new Dimension(300, 75)); this.quickIn.setBorder(BorderFactory.createTitledBorder("Quick Input")); quickInPanel.add(this.quickIn, BorderLayout.CENTER); this.syncButton = new JButton("Sync"); this.syncButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new SyncThread(Main.this).start(); } }); quickInPanel.add(this.syncButton, BorderLayout.EAST); this.getContentPane().add(quickInPanel, BorderLayout.NORTH); this.tree = new JTree(taskTree.getTreeModel()); DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer() { public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; Object newVal = htmlFilter(String.valueOf(node.getUserObject())); if (node.getChildCount() > 0 && !tree.isExpanded(new TreePath(node.getPath()))) { DefaultMutableTreeNode firstLeaf = (DefaultMutableTreeNode) node.getFirstLeaf(); newVal = htmlFilter(String.valueOf(node.getUserObject())) + " <span style='color:silver;font-style:italic'>" + "(" + String.valueOf(firstLeaf.getUserObject()) + ")</span>"; } newVal = "<html>" + newVal + "</html>"; return super.getTreeCellRendererComponent(tree, newVal, selected, expanded, leaf, row, hasFocus); } }; ImageIcon bulletIcon = new ImageIcon(Main.class.getResource("bullet.gif")); renderer.setLeafIcon(bulletIcon); renderer.setOpenIcon(bulletIcon); renderer.setClosedIcon(bulletIcon); renderer.setBorder(BorderFactory.createEmptyBorder(4, 0, 4, 0)); this.tree.setCellRenderer(renderer); this.tree.setRootVisible(false); this.tree.setShowsRootHandles(true); this.tree.addMouseListener(new MouseAdapter() { protected void doSelectRow(MouseEvent arg0) { int row = tree.getRowForLocation(arg0.getX(), arg0.getY()); if (row != -1) { tree.setSelectionRow(row); if (arg0.isPopupTrigger()) { popup.show(tree, arg0.getX(), arg0.getY()); } } } public void mousePressed(MouseEvent arg0) { doSelectRow(arg0); } public void mouseReleased(MouseEvent arg0) { doSelectRow(arg0); } }); JScrollPane treeScroll = new JScrollPane(tree); treeScroll.setBorder(BorderFactory.createTitledBorder("Task List")); this.getContentPane().add(treeScroll, BorderLayout.CENTER); this.popup = new JPopupMenu(); JMenuItem addBefore = new JMenuItem("Add Before"); addBefore.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DefaultMutableTreeNode selected = getSelectedNode(); DefaultMutableTreeNode parent = (DefaultMutableTreeNode) selected.getParent(); int pos = parent.getIndex(selected); promptAndInsert(parent, pos); try { Main.this.taskTree.changesMade(); } catch (Exception ex) { error(ex.getMessage()); } } }); this.popup.add(addBefore); JMenuItem addAfter = new JMenuItem("Add After"); addAfter.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DefaultMutableTreeNode selected = getSelectedNode(); DefaultMutableTreeNode parent = (DefaultMutableTreeNode) selected.getParent(); int pos = parent.getIndex(selected) + 1; promptAndInsert(parent, pos); try { Main.this.taskTree.changesMade(); } catch (Exception ex) { error(ex.getMessage()); } } }); this.popup.add(addAfter); JMenuItem addNested = new JMenuItem("Add Nested"); addNested.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DefaultMutableTreeNode selected = getSelectedNode(); int pos = selected.getChildCount(); promptAndInsert(selected, pos); try { Main.this.taskTree.changesMade(); } catch (Exception ex) { ex.getMessage(); } } }); this.popup.add(addNested); this.popup.add(new JSeparator()); JMenuItem moveTop = new JMenuItem("Move to Top"); moveTop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DefaultMutableTreeNode selected = getSelectedNode(); DefaultMutableTreeNode parent = (DefaultMutableTreeNode) selected.getParent(); moveTask(selected, parent, 0); try { Main.this.taskTree.changesMade(); } catch (Exception ex) { error(ex.getMessage()); } } }); this.popup.add(moveTop); JMenuItem moveUp = new JMenuItem("Move Up"); moveUp.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DefaultMutableTreeNode selected = getSelectedNode(); DefaultMutableTreeNode parent = (DefaultMutableTreeNode) selected.getParent(); int pos = Math.max(parent.getIndex(selected) - 1, 0); moveTask(selected, parent, pos); try { Main.this.taskTree.changesMade(); } catch (Exception ex) { error(ex.getMessage()); } } }); this.popup.add(moveUp); JMenuItem moveDown = new JMenuItem("Move Down"); moveDown.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DefaultMutableTreeNode selected = getSelectedNode(); DefaultMutableTreeNode parent = (DefaultMutableTreeNode) selected.getParent(); int pos = Math.min(parent.getIndex(selected) + 1, parent.getChildCount() - 1); moveTask(selected, parent, pos); try { Main.this.taskTree.changesMade(); } catch (Exception ex) { error(ex.getMessage()); } } }); this.popup.add(moveDown); JMenuItem moveBottom = new JMenuItem("Move to Bottom"); moveBottom.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DefaultMutableTreeNode selected = getSelectedNode(); DefaultMutableTreeNode parent = (DefaultMutableTreeNode) selected.getParent(); moveTask(selected, parent, parent.getChildCount() - 1); try { Main.this.taskTree.changesMade(); } catch (Exception ex) { error(ex.getMessage()); } } }); this.popup.add(moveBottom); this.popup.add(new JSeparator()); JMenuItem rename = new JMenuItem("Edit"); rename.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DefaultMutableTreeNode selected = getSelectedNode(); String newText = prompt((String) selected.getUserObject()); if (newText != null && newText.length() > 0) { selected.setUserObject(newText); Main.this.taskTree.getTreeModel().reload(selected); try { Main.this.taskTree.changesMade(); } catch (Exception ex) { error(ex.getMessage()); } } } }); this.popup.add(rename); JMenuItem delete = new JMenuItem("Delete"); delete.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { promptAndRemove(getSelectedNode()); try { Main.this.taskTree.changesMade(); } catch (Exception ex) { error(ex.getMessage()); } } }); this.popup.add(delete); this.setVisible(true); loadConfig(); load(); syncButton.setVisible(this.taskTree.hasSyncCapability()); }
From source file:com.sec.ose.osi.ui.frm.main.identification.common.JComboLicenseName.java
public JComboLicenseName() { final JTextField editor; this.initLicenseComboBox(); this.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (isEnabled()) { if (e.getActionCommand().equals("comboBoxChanged") || e.getActionCommand().equals("comboBoxEdited")) { if (getSelectedIndex() > 0) { setSelectedIndex(getSelectedIndex()); IdentifyMediator.getInstance() .setSelectedLicenseName(String.valueOf(getSelectedItem())); log.debug("selected license name : " + IdentifyMediator.getInstance().getSelectedLicenseName()); } else { IdentifyMediator.getInstance().setSelectedLicenseName(""); }//from w w w. j a v a2s.co m } } } }); editor = (JTextField) this.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) { hidePopup(); return; } String str = editor.getText(); if (getComponentCount() > 0) { removeAllItems(); } addItem(str); try { String tmpLicense = null; ArrayList<String> AllLicenseList = new ArrayList<String>(); AllLicenseList = LicenseAPIWrapper.getAllLicenseList(); if (str.length() > 0) { for (int i = 0; i < AllLicenseList.size(); i++) { tmpLicense = AllLicenseList.get(i); if (tmpLicense.toLowerCase().startsWith(str.toLowerCase())) addItem(tmpLicense); } } else { for (int i = 0; i < AllLicenseList.size(); i++) { addItem(AllLicenseList.get(i)); } } } catch (Exception e1) { log.warn(e1.getMessage()); } hidePopup(); if (str.length() > 0) showPopup(); } }); editor.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { if (editor.getText().length() > 0) showPopup(); } public void focusLost(FocusEvent e) { hidePopup(); } }); }
From source file:Main.java
static String getKeyText(int keyCode) { if (keyCode >= KeyEvent.VK_0 && keyCode <= KeyEvent.VK_9 || keyCode >= KeyEvent.VK_A && keyCode <= KeyEvent.VK_Z) { return String.valueOf((char) keyCode); }/*from ww w.j a v a 2s . c om*/ switch (keyCode) { case KeyEvent.VK_COMMA: return "COMMA"; case KeyEvent.VK_PERIOD: return "PERIOD"; case KeyEvent.VK_SLASH: return "SLASH"; case KeyEvent.VK_SEMICOLON: return "SEMICOLON"; case KeyEvent.VK_EQUALS: return "EQUALS"; case KeyEvent.VK_OPEN_BRACKET: return "OPEN_BRACKET"; case KeyEvent.VK_BACK_SLASH: return "BACK_SLASH"; case KeyEvent.VK_CLOSE_BRACKET: return "CLOSE_BRACKET"; case KeyEvent.VK_ENTER: return "ENTER"; case KeyEvent.VK_BACK_SPACE: return "BACK_SPACE"; case KeyEvent.VK_TAB: return "TAB"; case KeyEvent.VK_CANCEL: return "CANCEL"; case KeyEvent.VK_CLEAR: return "CLEAR"; case KeyEvent.VK_SHIFT: return "SHIFT"; case KeyEvent.VK_CONTROL: return "CONTROL"; case KeyEvent.VK_ALT: return "ALT"; case KeyEvent.VK_PAUSE: return "PAUSE"; case KeyEvent.VK_CAPS_LOCK: return "CAPS_LOCK"; case KeyEvent.VK_ESCAPE: return "ESCAPE"; case KeyEvent.VK_SPACE: return "SPACE"; case KeyEvent.VK_PAGE_UP: return "PAGE_UP"; case KeyEvent.VK_PAGE_DOWN: return "PAGE_DOWN"; case KeyEvent.VK_END: return "END"; case KeyEvent.VK_HOME: return "HOME"; case KeyEvent.VK_LEFT: return "LEFT"; case KeyEvent.VK_UP: return "UP"; case KeyEvent.VK_RIGHT: return "RIGHT"; case KeyEvent.VK_DOWN: return "DOWN"; case KeyEvent.VK_MULTIPLY: return "MULTIPLY"; case KeyEvent.VK_ADD: return "ADD"; case KeyEvent.VK_SEPARATOR: return "SEPARATOR"; case KeyEvent.VK_SUBTRACT: return "SUBTRACT"; case KeyEvent.VK_DECIMAL: return "DECIMAL"; case KeyEvent.VK_DIVIDE: return "DIVIDE"; case KeyEvent.VK_DELETE: return "DELETE"; case KeyEvent.VK_NUM_LOCK: return "NUM_LOCK"; case KeyEvent.VK_SCROLL_LOCK: return "SCROLL_LOCK"; case KeyEvent.VK_F1: return "F1"; case KeyEvent.VK_F2: return "F2"; case KeyEvent.VK_F3: return "F3"; case KeyEvent.VK_F4: return "F4"; case KeyEvent.VK_F5: return "F5"; case KeyEvent.VK_F6: return "F6"; case KeyEvent.VK_F7: return "F7"; case KeyEvent.VK_F8: return "F8"; case KeyEvent.VK_F9: return "F9"; case KeyEvent.VK_F10: return "F10"; case KeyEvent.VK_F11: return "F11"; case KeyEvent.VK_F12: return "F12"; case KeyEvent.VK_F13: return "F13"; case KeyEvent.VK_F14: return "F14"; case KeyEvent.VK_F15: return "F15"; case KeyEvent.VK_F16: return "F16"; case KeyEvent.VK_F17: return "F17"; case KeyEvent.VK_F18: return "F18"; case KeyEvent.VK_F19: return "F19"; case KeyEvent.VK_F20: return "F20"; case KeyEvent.VK_F21: return "F21"; case KeyEvent.VK_F22: return "F22"; case KeyEvent.VK_F23: return "F23"; case KeyEvent.VK_F24: return "F24"; case KeyEvent.VK_PRINTSCREEN: return "PRINTSCREEN"; case KeyEvent.VK_INSERT: return "INSERT"; case KeyEvent.VK_HELP: return "HELP"; case KeyEvent.VK_META: return "META"; case KeyEvent.VK_BACK_QUOTE: return "BACK_QUOTE"; case KeyEvent.VK_QUOTE: return "QUOTE"; case KeyEvent.VK_KP_UP: return "KP_UP"; case KeyEvent.VK_KP_DOWN: return "KP_DOWN"; case KeyEvent.VK_KP_LEFT: return "KP_LEFT"; case KeyEvent.VK_KP_RIGHT: return "KP_RIGHT"; case KeyEvent.VK_DEAD_GRAVE: return "DEAD_GRAVE"; case KeyEvent.VK_DEAD_ACUTE: return "DEAD_ACUTE"; case KeyEvent.VK_DEAD_CIRCUMFLEX: return "DEAD_CIRCUMFLEX"; case KeyEvent.VK_DEAD_TILDE: return "DEAD_TILDE"; case KeyEvent.VK_DEAD_MACRON: return "DEAD_MACRON"; case KeyEvent.VK_DEAD_BREVE: return "DEAD_BREVE"; case KeyEvent.VK_DEAD_ABOVEDOT: return "DEAD_ABOVEDOT"; case KeyEvent.VK_DEAD_DIAERESIS: return "DEAD_DIAERESIS"; case KeyEvent.VK_DEAD_ABOVERING: return "DEAD_ABOVERING"; case KeyEvent.VK_DEAD_DOUBLEACUTE: return "DEAD_DOUBLEACUTE"; case KeyEvent.VK_DEAD_CARON: return "DEAD_CARON"; case KeyEvent.VK_DEAD_CEDILLA: return "DEAD_CEDILLA"; case KeyEvent.VK_DEAD_OGONEK: return "DEAD_OGONEK"; case KeyEvent.VK_DEAD_IOTA: return "DEAD_IOTA"; case KeyEvent.VK_DEAD_VOICED_SOUND: return "DEAD_VOICED_SOUND"; case KeyEvent.VK_DEAD_SEMIVOICED_SOUND: return "DEAD_SEMIVOICED_SOUND"; case KeyEvent.VK_AMPERSAND: return "AMPERSAND"; case KeyEvent.VK_ASTERISK: return "ASTERISK"; case KeyEvent.VK_QUOTEDBL: return "QUOTEDBL"; case KeyEvent.VK_LESS: return "LESS"; case KeyEvent.VK_GREATER: return "GREATER"; case KeyEvent.VK_BRACELEFT: return "BRACELEFT"; case KeyEvent.VK_BRACERIGHT: return "BRACERIGHT"; case KeyEvent.VK_AT: return "AT"; case KeyEvent.VK_COLON: return "COLON"; case KeyEvent.VK_CIRCUMFLEX: return "CIRCUMFLEX"; case KeyEvent.VK_DOLLAR: return "DOLLAR"; case KeyEvent.VK_EURO_SIGN: return "EURO_SIGN"; case KeyEvent.VK_EXCLAMATION_MARK: return "EXCLAMATION_MARK"; case KeyEvent.VK_INVERTED_EXCLAMATION_MARK: return "INVERTED_EXCLAMATION_MARK"; case KeyEvent.VK_LEFT_PARENTHESIS: return "LEFT_PARENTHESIS"; case KeyEvent.VK_NUMBER_SIGN: return "NUMBER_SIGN"; case KeyEvent.VK_MINUS: return "MINUS"; case KeyEvent.VK_PLUS: return "PLUS"; case KeyEvent.VK_RIGHT_PARENTHESIS: return "RIGHT_PARENTHESIS"; case KeyEvent.VK_UNDERSCORE: return "UNDERSCORE"; case KeyEvent.VK_FINAL: return "FINAL"; case KeyEvent.VK_CONVERT: return "CONVERT"; case KeyEvent.VK_NONCONVERT: return "NONCONVERT"; case KeyEvent.VK_ACCEPT: return "ACCEPT"; case KeyEvent.VK_MODECHANGE: return "MODECHANGE"; case KeyEvent.VK_KANA: return "KANA"; case KeyEvent.VK_KANJI: return "KANJI"; case KeyEvent.VK_ALPHANUMERIC: return "ALPHANUMERIC"; case KeyEvent.VK_KATAKANA: return "KATAKANA"; case KeyEvent.VK_HIRAGANA: return "HIRAGANA"; case KeyEvent.VK_FULL_WIDTH: return "FULL_WIDTH"; case KeyEvent.VK_HALF_WIDTH: return "HALF_WIDTH"; case KeyEvent.VK_ROMAN_CHARACTERS: return "ROMAN_CHARACTERS"; case KeyEvent.VK_ALL_CANDIDATES: return "ALL_CANDIDATES"; case KeyEvent.VK_PREVIOUS_CANDIDATE: return "PREVIOUS_CANDIDATE"; case KeyEvent.VK_CODE_INPUT: return "CODE_INPUT"; case KeyEvent.VK_JAPANESE_KATAKANA: return "JAPANESE_KATAKANA"; case KeyEvent.VK_JAPANESE_HIRAGANA: return "JAPANESE_HIRAGANA"; case KeyEvent.VK_JAPANESE_ROMAN: return "JAPANESE_ROMAN"; case KeyEvent.VK_KANA_LOCK: return "KANA_LOCK"; case KeyEvent.VK_INPUT_METHOD_ON_OFF: return "INPUT_METHOD_ON_OFF"; case KeyEvent.VK_AGAIN: return "AGAIN"; case KeyEvent.VK_UNDO: return "UNDO"; case KeyEvent.VK_COPY: return "COPY"; case KeyEvent.VK_PASTE: return "PASTE"; case KeyEvent.VK_CUT: return "CUT"; case KeyEvent.VK_FIND: return "FIND"; case KeyEvent.VK_PROPS: return "PROPS"; case KeyEvent.VK_STOP: return "STOP"; case KeyEvent.VK_COMPOSE: return "COMPOSE"; case KeyEvent.VK_ALT_GRAPH: return "ALT_GRAPH"; } if (keyCode >= KeyEvent.VK_NUMPAD0 && keyCode <= KeyEvent.VK_NUMPAD9) { char c = (char) (keyCode - KeyEvent.VK_NUMPAD0 + '0'); return "NUMPAD" + c; } return "unknown(0x" + Integer.toString(keyCode, 16) + ")"; }
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;// w ww.ja v a 2 s .c o m } 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:Main.java
static String getKeyText(int keyCode) { if (keyCode >= KeyEvent.VK_0 && keyCode <= KeyEvent.VK_9 || keyCode >= KeyEvent.VK_A && keyCode <= KeyEvent.VK_Z) { return String.valueOf((char) keyCode); }// w w w . j a v a 2s . c o m switch (keyCode) { case KeyEvent.VK_COMMA: return "COMMA"; case KeyEvent.VK_PERIOD: return "PERIOD"; case KeyEvent.VK_SLASH: return "SLASH"; case KeyEvent.VK_SEMICOLON: return "SEMICOLON"; case KeyEvent.VK_EQUALS: return "EQUALS"; case KeyEvent.VK_OPEN_BRACKET: return "OPEN_BRACKET"; case KeyEvent.VK_BACK_SLASH: return "BACK_SLASH"; case KeyEvent.VK_CLOSE_BRACKET: return "CLOSE_BRACKET"; case KeyEvent.VK_ENTER: return "ENTER"; case KeyEvent.VK_BACK_SPACE: return "BACK_SPACE"; case KeyEvent.VK_TAB: return "TAB"; case KeyEvent.VK_CANCEL: return "CANCEL"; case KeyEvent.VK_CLEAR: return "CLEAR"; case KeyEvent.VK_SHIFT: return "SHIFT"; case KeyEvent.VK_CONTROL: return "CONTROL"; case KeyEvent.VK_ALT: return "ALT"; case KeyEvent.VK_PAUSE: return "PAUSE"; case KeyEvent.VK_CAPS_LOCK: return "CAPS_LOCK"; case KeyEvent.VK_ESCAPE: return "ESCAPE"; case KeyEvent.VK_SPACE: return "SPACE"; case KeyEvent.VK_PAGE_UP: return "PAGE_UP"; case KeyEvent.VK_PAGE_DOWN: return "PAGE_DOWN"; case KeyEvent.VK_END: return "END"; case KeyEvent.VK_HOME: return "HOME"; case KeyEvent.VK_LEFT: return "LEFT"; case KeyEvent.VK_UP: return "UP"; case KeyEvent.VK_RIGHT: return "RIGHT"; case KeyEvent.VK_DOWN: return "DOWN"; // numpad numeric keys handled below case KeyEvent.VK_MULTIPLY: return "MULTIPLY"; case KeyEvent.VK_ADD: return "ADD"; case KeyEvent.VK_SEPARATOR: return "SEPARATOR"; case KeyEvent.VK_SUBTRACT: return "SUBTRACT"; case KeyEvent.VK_DECIMAL: return "DECIMAL"; case KeyEvent.VK_DIVIDE: return "DIVIDE"; case KeyEvent.VK_DELETE: return "DELETE"; case KeyEvent.VK_NUM_LOCK: return "NUM_LOCK"; case KeyEvent.VK_SCROLL_LOCK: return "SCROLL_LOCK"; case KeyEvent.VK_F1: return "F1"; case KeyEvent.VK_F2: return "F2"; case KeyEvent.VK_F3: return "F3"; case KeyEvent.VK_F4: return "F4"; case KeyEvent.VK_F5: return "F5"; case KeyEvent.VK_F6: return "F6"; case KeyEvent.VK_F7: return "F7"; case KeyEvent.VK_F8: return "F8"; case KeyEvent.VK_F9: return "F9"; case KeyEvent.VK_F10: return "F10"; case KeyEvent.VK_F11: return "F11"; case KeyEvent.VK_F12: return "F12"; case KeyEvent.VK_F13: return "F13"; case KeyEvent.VK_F14: return "F14"; case KeyEvent.VK_F15: return "F15"; case KeyEvent.VK_F16: return "F16"; case KeyEvent.VK_F17: return "F17"; case KeyEvent.VK_F18: return "F18"; case KeyEvent.VK_F19: return "F19"; case KeyEvent.VK_F20: return "F20"; case KeyEvent.VK_F21: return "F21"; case KeyEvent.VK_F22: return "F22"; case KeyEvent.VK_F23: return "F23"; case KeyEvent.VK_F24: return "F24"; case KeyEvent.VK_PRINTSCREEN: return "PRINTSCREEN"; case KeyEvent.VK_INSERT: return "INSERT"; case KeyEvent.VK_HELP: return "HELP"; case KeyEvent.VK_META: return "META"; case KeyEvent.VK_BACK_QUOTE: return "BACK_QUOTE"; case KeyEvent.VK_QUOTE: return "QUOTE"; case KeyEvent.VK_KP_UP: return "KP_UP"; case KeyEvent.VK_KP_DOWN: return "KP_DOWN"; case KeyEvent.VK_KP_LEFT: return "KP_LEFT"; case KeyEvent.VK_KP_RIGHT: return "KP_RIGHT"; case KeyEvent.VK_DEAD_GRAVE: return "DEAD_GRAVE"; case KeyEvent.VK_DEAD_ACUTE: return "DEAD_ACUTE"; case KeyEvent.VK_DEAD_CIRCUMFLEX: return "DEAD_CIRCUMFLEX"; case KeyEvent.VK_DEAD_TILDE: return "DEAD_TILDE"; case KeyEvent.VK_DEAD_MACRON: return "DEAD_MACRON"; case KeyEvent.VK_DEAD_BREVE: return "DEAD_BREVE"; case KeyEvent.VK_DEAD_ABOVEDOT: return "DEAD_ABOVEDOT"; case KeyEvent.VK_DEAD_DIAERESIS: return "DEAD_DIAERESIS"; case KeyEvent.VK_DEAD_ABOVERING: return "DEAD_ABOVERING"; case KeyEvent.VK_DEAD_DOUBLEACUTE: return "DEAD_DOUBLEACUTE"; case KeyEvent.VK_DEAD_CARON: return "DEAD_CARON"; case KeyEvent.VK_DEAD_CEDILLA: return "DEAD_CEDILLA"; case KeyEvent.VK_DEAD_OGONEK: return "DEAD_OGONEK"; case KeyEvent.VK_DEAD_IOTA: return "DEAD_IOTA"; case KeyEvent.VK_DEAD_VOICED_SOUND: return "DEAD_VOICED_SOUND"; case KeyEvent.VK_DEAD_SEMIVOICED_SOUND: return "DEAD_SEMIVOICED_SOUND"; case KeyEvent.VK_AMPERSAND: return "AMPERSAND"; case KeyEvent.VK_ASTERISK: return "ASTERISK"; case KeyEvent.VK_QUOTEDBL: return "QUOTEDBL"; case KeyEvent.VK_LESS: return "LESS"; case KeyEvent.VK_GREATER: return "GREATER"; case KeyEvent.VK_BRACELEFT: return "BRACELEFT"; case KeyEvent.VK_BRACERIGHT: return "BRACERIGHT"; case KeyEvent.VK_AT: return "AT"; case KeyEvent.VK_COLON: return "COLON"; case KeyEvent.VK_CIRCUMFLEX: return "CIRCUMFLEX"; case KeyEvent.VK_DOLLAR: return "DOLLAR"; case KeyEvent.VK_EURO_SIGN: return "EURO_SIGN"; case KeyEvent.VK_EXCLAMATION_MARK: return "EXCLAMATION_MARK"; case KeyEvent.VK_INVERTED_EXCLAMATION_MARK: return "INVERTED_EXCLAMATION_MARK"; case KeyEvent.VK_LEFT_PARENTHESIS: return "LEFT_PARENTHESIS"; case KeyEvent.VK_NUMBER_SIGN: return "NUMBER_SIGN"; case KeyEvent.VK_MINUS: return "MINUS"; case KeyEvent.VK_PLUS: return "PLUS"; case KeyEvent.VK_RIGHT_PARENTHESIS: return "RIGHT_PARENTHESIS"; case KeyEvent.VK_UNDERSCORE: return "UNDERSCORE"; case KeyEvent.VK_FINAL: return "FINAL"; case KeyEvent.VK_CONVERT: return "CONVERT"; case KeyEvent.VK_NONCONVERT: return "NONCONVERT"; case KeyEvent.VK_ACCEPT: return "ACCEPT"; case KeyEvent.VK_MODECHANGE: return "MODECHANGE"; case KeyEvent.VK_KANA: return "KANA"; case KeyEvent.VK_KANJI: return "KANJI"; case KeyEvent.VK_ALPHANUMERIC: return "ALPHANUMERIC"; case KeyEvent.VK_KATAKANA: return "KATAKANA"; case KeyEvent.VK_HIRAGANA: return "HIRAGANA"; case KeyEvent.VK_FULL_WIDTH: return "FULL_WIDTH"; case KeyEvent.VK_HALF_WIDTH: return "HALF_WIDTH"; case KeyEvent.VK_ROMAN_CHARACTERS: return "ROMAN_CHARACTERS"; case KeyEvent.VK_ALL_CANDIDATES: return "ALL_CANDIDATES"; case KeyEvent.VK_PREVIOUS_CANDIDATE: return "PREVIOUS_CANDIDATE"; case KeyEvent.VK_CODE_INPUT: return "CODE_INPUT"; case KeyEvent.VK_JAPANESE_KATAKANA: return "JAPANESE_KATAKANA"; case KeyEvent.VK_JAPANESE_HIRAGANA: return "JAPANESE_HIRAGANA"; case KeyEvent.VK_JAPANESE_ROMAN: return "JAPANESE_ROMAN"; case KeyEvent.VK_KANA_LOCK: return "KANA_LOCK"; case KeyEvent.VK_INPUT_METHOD_ON_OFF: return "INPUT_METHOD_ON_OFF"; case KeyEvent.VK_AGAIN: return "AGAIN"; case KeyEvent.VK_UNDO: return "UNDO"; case KeyEvent.VK_COPY: return "COPY"; case KeyEvent.VK_PASTE: return "PASTE"; case KeyEvent.VK_CUT: return "CUT"; case KeyEvent.VK_FIND: return "FIND"; case KeyEvent.VK_PROPS: return "PROPS"; case KeyEvent.VK_STOP: return "STOP"; case KeyEvent.VK_COMPOSE: return "COMPOSE"; case KeyEvent.VK_ALT_GRAPH: return "ALT_GRAPH"; } if (keyCode >= KeyEvent.VK_NUMPAD0 && keyCode <= KeyEvent.VK_NUMPAD9) { char c = (char) (keyCode - KeyEvent.VK_NUMPAD0 + '0'); return "NUMPAD" + c; } return "unknown(0x" + Integer.toString(keyCode, 16) + ")"; }
From source file:com.sec.ose.osi.ui.frm.main.identification.JComboProjectName.java
public JComboProjectName() { this.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE); this.setEditable(true); this.setPreferredSize(new Dimension(400, 27)); this.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { long start = System.currentTimeMillis(); actionOnProjectSelectedonProjectComboBox(); long end = System.currentTimeMillis(); log.debug(//from w ww . j a v a2 s . c om "[JComboProjectName.addActionListener()] Project Loding TIME : " + (end - start) / 1000.0); } }); final JTextField editor = (JTextField) this.getEditor().getEditorComponent(); editor.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { char ch = e.getKeyChar(); int count = 0; String newProjectName = editor.getText(); if (ch != KeyEvent.VK_ENTER && ch != KeyEvent.VK_BACK_SPACE && (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch))) { return; } if (newProjectName.length() <= 0 && ch == KeyEvent.VK_BACK_SPACE) { count++; if (count >= 2) { String projectName = IdentifyMediator.getInstance().getSelectedProjectName(); ((JTextField) JComboProjectName.this.getEditor().getEditorComponent()).setText(projectName); count = 0; return; } } if (JComboProjectName.this.getComponentCount() > 0) { JComboProjectName.this.removeAllItems(); } JComboProjectName.this.addItem(newProjectName); try { Collection<OSIProjectInfo> ProjectsInfo = OSIProjectInfoMgr.getInstance().getAllProjects(); String tmpProName = null; boolean bAnalysis = false; if (newProjectName.length() > 0) { for (OSIProjectInfo projectInfo : ProjectsInfo) { tmpProName = projectInfo.getProjectName(); bAnalysis = projectInfo.isAnalyzed(); if (tmpProName.toLowerCase().contains(newProjectName.toLowerCase()) && bAnalysis) JComboProjectName.this.addItem(tmpProName); } if (JComboProjectName.this.getItemCount() <= 1) { JComboProjectName.this.removeAllItems(); JOptionPane.showOptionDialog(null, "There is no project.", "Project Filter", JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE, null, buttonOK, "OK"); } } else { for (OSIProjectInfo projectInfo : ProjectsInfo) { if (projectInfo.isManaged() == true && projectInfo.isAnalyzed()) { JComboProjectName.this.addItem(projectInfo.getProjectName()); } } JComboProjectName.this.addItem(DIVIDER_LINE); for (OSIProjectInfo projectInfo : ProjectsInfo) { if (projectInfo.isManaged() == false && projectInfo.isAnalyzed()) { JComboProjectName.this.addItem(projectInfo.getProjectName()); } } ((JTextField) JComboProjectName.this.getEditor().getEditorComponent()).setText(""); } } catch (Exception e1) { log.warn(e1.getMessage()); } JComboProjectName.this.hidePopup(); if (newProjectName.length() > 0) JComboProjectName.this.showPopup(); } }); }
From source file:net.pandoragames.far.ui.swing.dialog.SubWindow.java
/** * Registers an event listener for the Enter key on some text component. * /*from w w w. ja v a 2s . c om*/ * @param component on which to register * @param action what is registered */ protected void registerEnterKeyListener(JTextComponent component, Action action) { component.getKeymap().addActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), action); }
From source file:com.anrisoftware.prefdialog.miscswing.lists.ActionList.java
private void setupList() { list.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override// www . j a va 2 s .c om public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { fireAction(); } } }); list.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { fireAction(); } }); list.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getExtendedKeyCode() == KeyEvent.VK_SPACE) { fireAction(); } if (e.getExtendedKeyCode() == KeyEvent.VK_ENTER) { fireAction(); } } }); }
From source file:modmanager.MainWindow.java
private void registerSearch() { searchField.addKeyListener(new KeyListener() { @Override//from ww w . j a v a 2s.c om public void keyTyped(KeyEvent ke) { } @Override public void keyPressed(KeyEvent ke) { } @Override public void keyReleased(KeyEvent ke) { String sub = searchField.getText(); for (Modification mod : modifications.getModifications()) { if (mod.getName().toLowerCase().contains(sub.toLowerCase())) { modificationList.setSelectedValue(mod, true); if (ke.getKeyCode() == KeyEvent.VK_ENTER) { modificationList.requestFocus(); searchField.setText(""); } break; } } } }); }