An abstract class that minimizes the effort required to implement
a type converter. A type converter is a ValueModel that converts the type
of an object being held as a value in one ValueModel into another type.
More formally, a converting ValueModel VM1 converts the type
T2 of an object being held as a value in one ValueModel VM2
into another type T1. When reading a value from VM1,
instances of T2 are read from VM2 and are converted to T1. When storing
a new value to VM1, the type converter will perform the inverse conversion
and will convert an instance of T1 to T2.
The conversion must be performed when reading and writing values,
as well as in the change notification. This class specifies abstract
methods for the conversion from source to output, which is used to
convert in #getValue and in the change notification.
For the write conversion you must implement #setValue .
Most converters can set values converted by #convertFromSubject
with #setValue . However, a converter may reject subject values
to be converted and may reject values to be set - as any ValueModel.
Type converters should be used judiciously and only to bridge two
ValueModel s. Converters often use a generic but weak
conversion, and so can be limited w.r.t. to localized
formatting conventions.
When binding non-String values to a text UI component, consider
using a
javax.swing.JFormattedTextField . Formatted text fields
provide a powerful means to convert strings to objects and handle many cases
that arise around invalid input. Formatted text fields can be bound
to ValueModel s using the
com.jgoodies.binding.beans.PropertyConnector class.
author: Karsten Lentzsch version: $Revision: 1.9 $ See Also: ValueModel See Also: ConverterFactory See Also: javax.swing.JFormattedTextField See Also: com.jgoodies.binding.beans.PropertyConnector |