The DefaultFormatterFactory Class
DefaultFormatterFactory
is Swing’s only concrete implementation of AbstractFormatterFactory
. It holds one or more
formatters and decides which one to give to the field depending on
whether the field has focus and whether the field’s value
is null
.
Properties
Table 20-7 shows
the formatter properties defined by DefaultFormatterFactory
.
Table 20-7. DefaultFormatterFactory properties
Property | Data type | get | is | set | Default value |
---|---|---|---|---|---|
defaultFormatter | JFormattedTextField.AbstractFormatter | · | · | null | |
displayFormatter | JFormattedTextField.AbstractFormatter | · | · | null | |
editFormatter | JFormattedTextField.AbstractFormatter | · | · | null | |
nullFormatter | JFormattedTextField.AbstractFormatter | · | · | null |
defaultFormatter
is used if
one of the other formatter properties is null
. It is common for defaultFormatter
to be the only non-null
formatter property, in which case the
field uses the defaultFormatter
exclusively.
displayFormatter
is intended
for use when the field does not have focus. It may be null
, in which case defaultFormatter
is used instead.
editFormatter
is intended for
use when the field has focus. It may be null
, in which case defaultFormatter
is used instead.
nullFormatter
is intended for
use when the field’s content is null
. It may be null
, in which case displayFormatter
or editFormatter
(depending on whether the
field has focus) is used instead. (If displayFormatter
/editFormatter
is also null
, defaultFormatter
is used.)
Constructors
- public DefaultFormatterFactory( )
Create a new
DefaultFormatterFactory ...
Get Java Swing, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.