// Implementation of keyPressed public void keyPressed(KeyEvent e) { if (e.getSource() == searchbutton && e.getKeyCode() == KeyEvent.VK_ENTER) { update(); } else if (e.getSource() == addfeesbutton && e.getKeyCode() == KeyEvent.VK_ENTER) { addFees(); } else if (e.getSource() == addcoursebutton && e.getKeyCode() == KeyEvent.VK_ENTER) { addCourse(); } }
public void keyPressed(KeyEvent ke) { if (ke.getKeyCode() == ke.VK_TAB) { int x = ((JTable) ke.getSource()).getSelectedColumn(); int y = ((JTable) ke.getSource()).getSelectedRow(); int maxX = ((JTable) ke.getSource()).getColumnCount(); int maxY = ((JTable) ke.getSource()).getRowCount(); TableModel tm = ((JTable) ke.getSource()).getModel(); if (x == maxX - 1 && y == maxY - 1) { ((DefaultTableModel) tm).addRow(new Object[maxX]); } } }
public void keyReleased(KeyEvent e) { int code = e.getKeyCode(); if (code == KeyEvent.VK_SPACE) { AbstractButton button = (AbstractButton) e.getSource(); button.putClientProperty(SPACEBAR_PRESSED, Boolean.FALSE); } }
public void keyPressed(KeyEvent e) { int code = e.getKeyCode(); if (code == KeyEvent.VK_SPACE) { AbstractButton button = (AbstractButton) e.getSource(); Boolean wasPressed = (Boolean) button.getClientProperty(SPACEBAR_PRESSED); if (wasPressed == null || wasPressed.booleanValue() == false) { button.putClientProperty(SPACEBAR_PRESSED, Boolean.TRUE); button.doClick(); } } }
@Override public void keyPressed(KeyEvent e) { // Accept "copy" key strokes KeyStroke ks = KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiers()); JComponent comp = (JComponent) e.getSource(); for (int i = 0; i < 3; i++) { InputMap im = comp.getInputMap(i); Object key = im.get(ks); if (defaultEditorKitCopyActionName.equals(key) || transferHandlerCopyActionName.equals(key)) { return; } } // Accept JTable navigation key strokes if (!tableNavigationKeys.contains(e.getKeyCode())) { e.consume(); } }