The InternationalFormatter Class

InternationalFormatter is a subclass of DefaultFormatter that delegates most of its work to an object of type java.text.Format (which is always a subclass since java.text.Format itself is abstract). Many of these subclasses provide internationalization support through awareness of locales, hence the name InternationalFormatter.

InternationalFormatter is rarely used directly. It is a repository for the common functionality of its two subclasses, DateFormatter and NumberFormatter.

Properties

Table 20-6 shows the properties defined by InternationalFormatter.

Table 20-6. InternationalFormatter properties

Property

Data type

get

is

set

Default value

format

java.text.Format

·

 

·

null

minimum

Comparable

·

 

·

null

maximum

Comparable

·

 

·

null

overwriteMode o

boolean

·

 

·

false

ooverridden

See also properties from the DefaultFormatter class (Table 20-3).

     

The format property is key to InternationalFormatter and is used by the valueToString( ) and stringToValue( ) methods to translate between the field’s Object and String representations. It can be set in the constructor or via the setFormat( ) method.

The minimum and maximum properties can constrain the value of the field. If minimum is not null, value may not be less than minimum. If maximum is not null, value may not be greater than maximum. These may be of any type that implements the Comparable interface. (Provided it hasn’t already been set, calling setMinimum( ) or setMaximum( ) also sets the formatter’s valueClass property.) ...

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.