Java Code Examples for javax.swing.JFormattedTextField#commitEdit()
The following examples show how to use
javax.swing.JFormattedTextField#commitEdit() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IntegerEditor.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
@Override public boolean stopCellEditing() { JFormattedTextField textField = (JFormattedTextField) getComponent(); if (textField.isEditValid()) { try { textField.commitEdit(); } catch (java.text.ParseException exc) { } } else { //text is invalid if (!userSaysRevert()) { //user wants to edit return false; //don't let the editor go away } } return super.stopCellEditing(); }
Example 2
Source File: IntegerEditor.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
@Override public boolean stopCellEditing() { JFormattedTextField textField = (JFormattedTextField) getComponent(); if (textField.isEditValid()) { try { textField.commitEdit(); } catch (java.text.ParseException exc) { } } else { //text is invalid if (!userSaysRevert()) { //user wants to edit return false; //don't let the editor go away } } return super.stopCellEditing(); }
Example 3
Source File: BaseIntervalPanel.java From nmonvisualizer with Apache License 2.0 | 6 votes |
protected final void requestFocus(final JFormattedTextField field) { field.requestFocus(); // hack to fix formatted text fields receiving focus programatically but not allowing // formatted edits try { field.commitEdit(); } catch (java.text.ParseException pe) { // ignore - value should be valid since formatter checked when focus was previously lost } SwingUtilities.invokeLater(new Runnable() { @Override public void run() { field.selectAll(); } }); }
Example 4
Source File: IntegerEditor.java From marathonv5 with Apache License 2.0 | 5 votes |
public boolean stopCellEditing() { JFormattedTextField ftf = (JFormattedTextField) getComponent(); if (ftf.isEditValid()) { try { ftf.commitEdit(); } catch (java.text.ParseException exc) { } } else { // text is invalid if (!userSaysRevert()) { // user wants to edit return false; // don't let the editor go away } } return super.stopCellEditing(); }