Skip to Main Content
Java Swing, 2nd Edition
book

Java Swing, 2nd Edition

by Dave Wood, Robert Eckstein, Marc Loy, James Elliott, Brian Cole
November 2002
Intermediate to advanced content levelIntermediate to advanced
1278 pages
38h 26m
English
O'Reilly Media, Inc.
Content preview from Java Swing, 2nd Edition

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java Threads, 3rd Edition

Java Threads, 3rd Edition

Scott Oaks, Henry Wong

Publisher Resources

ISBN: 0596004087Errata PageSupplemental Content