List of usage examples for java.awt.event KeyEvent getExtendedKeyCode
public int getExtendedKeyCode()
From source file:net.sf.jabref.gui.search.SearchBar.java
/** * Initializes the search text field/*from w w w . j ava 2s. co m*/ */ private void initSearchField() { searchField.setColumns(30); searchField.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.getExtendedKeyCode() == KeyEvent.VK_ESCAPE) { endSearch(); } } }); // Add autocompleter autoCompleteSupport = new AutoCompleteSupport<>(searchField); autoCompleteSupport.install(); // Add the global focus listener, so a menu item can see if this field was focused when an action was called. searchField.addFocusListener(Globals.getFocusListener()); // Search if user press enter searchField.addActionListener(e -> performSearch()); // Subscribe to changes to the text in the search field in order to "live search" JTextFieldChangeListenerUtil.addChangeListener(searchField, e -> performSearch()); }
From source file:com.farouk.projectapp.FirstGUI.java
private void jTable2KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTable2KeyReleased jList1.clearSelection();//from ww w . ja va 2s . c o m int row = jTable2.getSelectedRow(); String name = (jTable2.getModel().getValueAt(row, 0).toString()); if (evt.getExtendedKeyCode() == KeyEvent.VK_BACK_SPACE || evt.getExtendedKeyCode() == KeyEvent.VK_DELETE) { int decision = JOptionPane.showConfirmDialog(rootPane, "Do you really want to delete " + name + "?", "Remove a company", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.YES_OPTION) { SQLConnect.removeCompanyFromPortfolio(name, userID); UpdatejTable2(); SQLConnect.registerTotalChanges(userID, total); } } }