List of usage examples for javax.swing JTextField notifyAction
String notifyAction
To view the source code for javax.swing JTextField notifyAction.
Click Source Link
From source file:org.lisapark.octopus.swing.BaseFormattedTextField.java
/** * Invoked to process the key bindings for <code>ks</code> as the result * of the <code>KeyEvent</code> <code>e</code>. We override this method to make * sure that the text field has the proper action for when the user presses * the enter key//from w ww . j a va2s . co m * * @param ks the <code>KeyStroke</code> queried * @param e the <code>KeyEvent</code> * @param condition one of the following values: * <ul> * <li>JComponent.WHEN_FOCUSED * <li>JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT * <li>JComponent.WHEN_IN_FOCUSED_WINDOW * </ul> * @param pressed true if the key is pressed * @return true if there was a binding to an action, and the action * was enabled */ protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) { // we need to override this method to allow for handling of the delete key properly if (e.getKeyCode() == KeyEvent.VK_ENTER) { InputMap map = getInputMap(condition); ActionMap am = getActionMap(); if (map != null && am != null && isEnabled()) { Object binding = map.get(ks); Action action; // replace the nofify action if necessary if (binding != null && binding.equals(JTextField.notifyAction)) { action = am.get(binding); if (action != commitOnEnterAction) { am.put(JTextField.notifyAction, commitOnEnterAction); } } } } return super.processKeyBinding(ks, e, condition, pressed); }