com.jgoodies.validation.tutorial.formatted.formatter
Class CustomNumberFormatter
java.lang.Object
javax.swing.JFormattedTextField.AbstractFormatter
javax.swing.text.DefaultFormatter
javax.swing.text.InternationalFormatter
javax.swing.text.NumberFormatter
com.jgoodies.validation.tutorial.formatted.formatter.CustomNumberFormatter
- All Implemented Interfaces:
- Serializable, Cloneable
public final class CustomNumberFormatter
- extends NumberFormatter
Unlike its superclass NumberFormatter
, this class
converts non-negative integers to natural language strings:
Zero, One, Two, Three, More than three.
- Version:
- $Revision: 1.10 $
- Author:
- Karsten Lentzsch
- See Also:
JFormattedTextField
,
Serialized Form
CustomNumberFormatter
public CustomNumberFormatter()
- Constructs a
CustomNumberFormatter
.
CustomNumberFormatter
public CustomNumberFormatter(NumberFormat numberFormat)
- Constructs a
CustomNumberFormatter
using the given
NumberFormat
to convert strings to values.
- Parameters:
numberFormat
- the NumberFormat used to parse numbers
valueToString
public String valueToString(Object value)
throws ParseException
- Returns a String representation of the Object
value
.
This invokes format
on the current Format
.
In addition to the superclass behavior, this method formats the numbers
for zero, one, two, and three to the natural language strings.
- Overrides:
valueToString
in class InternationalFormatter
- Parameters:
value
- Value to convert
- Returns:
- String representation of value
- Throws:
ParseException
- if there is an error in the conversion
Copyright © 2003-2008 JGoodies Karsten Lentzsch. All Rights Reserved.