Package org.jdesktop.swingx.text
Class StrictNumberFormatter
- java.lang.Object
-
- javax.swing.JFormattedTextField.AbstractFormatter
-
- javax.swing.text.DefaultFormatter
-
- javax.swing.text.InternationalFormatter
-
- javax.swing.text.NumberFormatter
-
- org.jdesktop.swingx.text.StrictNumberFormatter
-
- All Implemented Interfaces:
Serializable,Cloneable
public class StrictNumberFormatter extends NumberFormatter
Experiment to work around Issue #1183-swingx: NumberEditorExt throws exception on getCellValue. Remaining issue: no visual error feedback if the expected number type exceeds its range.- Author:
- Jeanette Winzenburg
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description StrictNumberFormatter(NumberFormat format)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidsetMaximum(Comparable max)voidsetMinimum(Comparable minimum)voidsetValueClass(Class<?> valueClass)ObjectstringToValue(String text)Returns theObjectrepresentation of theStringtext, may be null.-
Methods inherited from class javax.swing.text.NumberFormatter
setFormat
-
Methods inherited from class javax.swing.text.InternationalFormatter
clone, getActions, getFields, getFormat, getMaximum, getMinimum, install, valueToString
-
Methods inherited from class javax.swing.text.DefaultFormatter
getAllowsInvalid, getCommitsOnValidEdit, getDocumentFilter, getNavigationFilter, getOverwriteMode, getValueClass, setAllowsInvalid, setCommitsOnValidEdit, setOverwriteMode
-
Methods inherited from class javax.swing.JFormattedTextField.AbstractFormatter
getFormattedTextField, invalidEdit, setEditValid, uninstall
-
-
-
-
Constructor Detail
-
StrictNumberFormatter
public StrictNumberFormatter(NumberFormat format)
- Parameters:
format-
-
-
Method Detail
-
setValueClass
public void setValueClass(Class<?> valueClass)
Overridden to automatically set the minimum/maximum to the boundaries of the Number type if it corresponds to a raw type, or null if not.
- Overrides:
setValueClassin classDefaultFormatter
-
setMaximum
public void setMaximum(Comparable max)
- Overrides:
setMaximumin classInternationalFormatter
-
setMinimum
public void setMinimum(Comparable minimum)
- Overrides:
setMinimumin classInternationalFormatter
-
stringToValue
public Object stringToValue(String text) throws ParseException
Returns theObjectrepresentation of theStringtext, may be null.- Overrides:
stringToValuein classInternationalFormatter- Parameters:
text-Stringto convert- Returns:
Objectrepresentation of text- Throws:
ParseException- if there is an error in the conversion
-
-