Formatter editor

JFormattedTextFields are used to display formatted data or to format user input in a locale sensitive way. The behaviour of a formatted text field is defined by its Formatter which can be one of:
IntegerFormatter (format and parse integer values),
CurrencyFormatter (format and parse currency values),
PercentFormatter (format and parse percent values),
NumberFormatter (format and parse integer or double values),
DateFormatter (format and parse dates) or
MaskFormatter (format arbitrary strings).
You open the Formatter editor by double-clicking the formatted text field.


The NumberFormatter dialog

IntegerFormatter Format and parse integer numbers.
CurrencyFormatter Format and parse currency values.
Note: For the formatter to parse a given input successfully, a user has to input the currency symbol at the right position.
PercentFormatter Format and parse percent values.
Note: For the formatter to parse a given input successfully, a user has to input the percent symbol at the right position.
NumberFormatter Format and parse integer or double values.
Min. fraction digits: The number of fraction digits always displayed.
Max. fraction digits: The maximum number of fraction digits to display.
Min. integer digits: The number of integer digits always displayed.
Max. integer digits: The maximum number of integer digits to display.
NullFormatter: Include a NullFormatter in the formatter factory which will display Display string if the formatted text field's value is null.
Change the Locale setting to see how numbers are formatted in different locales.


The DateFormatter dialog

First select between a format pattern or a format style. A format style is suitable for every locale, whereas a format pattern defines a fixed order of date/time elements which might not match the order of a distinct locale.
Pattern: Select one of the pre-defined format patterns or define your own (for a description of possible patterns, press Patterns...).
Style: You can define a Date style and a Time style, both can be set to OMIT, SHORT, MEDIUM or LONG.
Value: Select date values with the spinner and see, how they will be formatted.
NullFormatter: Include a NullFormatter in the formatter factory which will display Display string if the formatted text field's value is null.
Change the Locale setting to see how dates are formatted locale sensitive.


The MaskFormatter dialog

A mask formatter lets you use a character mask to specify the set of characters that can be entered at each position in the field.
Mask: Define the mask to use with the formatter (for a description of possible mask definitions, press Patterns...).
Placeholder character: The character to use in place of characters that are not present in the value, ie the user must fill them in.
Valid characters: Allows for further restricting of the characters that can be input.
Invalid characters: Allows for further restricting of the characters that can be input.
allowsInvalid: Sets whether or not the value being edited is allowed to be invalid for a length of time (that is, stringToValue throws a ParseException). It is often convenient to allow the user to temporarily input an invalid value.
commitsOnValidEdit: Sets when edits are published back to the JFormattedTextField. If true, commitEdit is invoked after every valid edit (any time the text is edited). On the other hand, if this is false than the DefaultFormatter does not publish edits back to the JFormattedTextField. As such, the only time the value of the JFormattedTextField will change is when commitEdit is invoked on JFormattedTextField, typically when enter is pressed or focus leaves the JFormattedTextField.
overwriteMode: Configures the behavior when inserting characters. If overwriteMode is true, new characters overwrite existing characters in the model.
valueContainsLiteralCharacters: If selected, the returned value will also contain the literal characters in mask.
NullFormatter: Include a NullFormatter in the formatter factory which will display Display string if the formatted text field's value is null.

See also:
RadiSpinner