List of usage examples for javax.swing JFormattedTextField COMMIT_OR_REVERT
int COMMIT_OR_REVERT
To view the source code for javax.swing JFormattedTextField COMMIT_OR_REVERT.
Click Source Link
commitEdit
should be invoked. From source file:org.revager.tools.GUITools.java
/** * Formats the given spinner.//from w w w . j a v a 2s. c o m * * @param sp * the spinner */ public static void formatSpinner(JSpinner sp, boolean hideBorder) { JSpinner.DefaultEditor defEditor = (JSpinner.DefaultEditor) sp.getEditor(); JFormattedTextField ftf = defEditor.getTextField(); ftf.setFocusLostBehavior(JFormattedTextField.COMMIT_OR_REVERT); InternationalFormatter intFormatter = (InternationalFormatter) ftf.getFormatter(); DecimalFormat decimalFormat = (DecimalFormat) intFormatter.getFormat(); decimalFormat.applyPattern("00"); DecimalFormatSymbols geSymbols = new DecimalFormatSymbols(Data.getInstance().getLocale()); decimalFormat.setDecimalFormatSymbols(geSymbols); if (hideBorder) { sp.setBorder(null); } }