List of usage examples for javax.swing.text DateFormatter setCommitsOnValidEdit
public void setCommitsOnValidEdit(boolean commit)
JFormattedTextField
. From source file:dk.dma.epd.shore.gui.views.SendRouteDialog.java
/** * Configures the given date picker and associated time spinner * /* www . j a v a 2 s. c o m*/ * @param picker * the date picker * @param spinner * the time spinner */ private void initDatePicker(JXDatePicker picker, JSpinner spinner) { picker.setFormats(new SimpleDateFormat("E dd/MM/yyyy")); picker.addPropertyChangeListener("date", this); DateEditor editor = new JSpinner.DateEditor(spinner, "HH:mm"); DateFormatter formatter = (DateFormatter) editor.getTextField().getFormatter(); formatter.setAllowsInvalid(false); formatter.setOverwriteMode(true); formatter.setCommitsOnValidEdit(true); spinner.setEditor(editor); spinner.addChangeListener(new SpinnerChangeListener()); }
From source file:dk.dma.epd.common.prototype.gui.route.RoutePropertiesDialogCommon.java
/** * Configures the given date picker and associated time spinner * @param picker the date picker/*from ww w .j a va 2s . c o m*/ * @param spinner the time spinner */ private void initDatePicker(JXDatePicker picker, JSpinner spinner) { picker.setFormats(new SimpleDateFormat("E dd/MM/yyyy")); picker.addPropertyChangeListener("date", this); DateEditor editor = new JSpinner.DateEditor(spinner, "HH:mm"); DateFormatter formatter = (DateFormatter) editor.getTextField().getFormatter(); formatter.setAllowsInvalid(false); formatter.setOverwriteMode(true); formatter.setCommitsOnValidEdit(true); spinner.setEditor(editor); spinner.addChangeListener(new SpinnerChangeListener()); // Set the enabled state picker.setEnabled(!readOnlyRoute); spinner.setEnabled(!readOnlyRoute); }