Class StrictNumberFormatter

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

    public class StrictNumberFormatter
    extends javax.swing.text.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​(java.text.NumberFormat format)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void setMaximum​(java.lang.Comparable max)  
      void setMinimum​(java.lang.Comparable minimum)  
      void setValueClass​(java.lang.Class<?> valueClass)
      java.lang.Object stringToValue​(java.lang.String text)
      Returns the Object representation of the String text, 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
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StrictNumberFormatter

        public StrictNumberFormatter​(java.text.NumberFormat format)
        Parameters:
        format -
    • Method Detail

      • setValueClass

        public void setValueClass​(java.lang.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:
        setValueClass in class javax.swing.text.DefaultFormatter
      • setMaximum

        public void setMaximum​(java.lang.Comparable max)
        Overrides:
        setMaximum in class javax.swing.text.InternationalFormatter
      • setMinimum

        public void setMinimum​(java.lang.Comparable minimum)
        Overrides:
        setMinimum in class javax.swing.text.InternationalFormatter
      • stringToValue

        public java.lang.Object stringToValue​(java.lang.String text)
                                       throws java.text.ParseException
        Returns the Object representation of the String text, may be null.
        Overrides:
        stringToValue in class javax.swing.text.InternationalFormatter
        Parameters:
        text - String to convert
        Returns:
        Object representation of text
        Throws:
        java.text.ParseException - if there is an error in the conversion