Search in sources :

Example 1 with InternationalFormatter

use of javax.swing.text.InternationalFormatter in project EnrichmentMapApp by BaderLab.

the class CutoffPropertiesPanel method getFormatterFactory.

private static AbstractFormatterFactory getFormatterFactory(boolean scientific) {
    return new AbstractFormatterFactory() {

        @Override
        public AbstractFormatter getFormatter(JFormattedTextField tf) {
            NumberFormat format = scientific ? new DecimalFormat("0.######E00") : new DecimalFormat();
            format.setMinimumFractionDigits(scientific ? 0 : 1);
            format.setMaximumFractionDigits(12);
            InternationalFormatter formatter = new InternationalFormatter(format);
            formatter.setAllowsInvalid(true);
            return formatter;
        }
    };
}
Also used : DecimalFormat(java.text.DecimalFormat) InternationalFormatter(javax.swing.text.InternationalFormatter) JFormattedTextField(javax.swing.JFormattedTextField) AbstractFormatterFactory(javax.swing.JFormattedTextField.AbstractFormatterFactory) NumberFormat(java.text.NumberFormat)

Aggregations

DecimalFormat (java.text.DecimalFormat)1 NumberFormat (java.text.NumberFormat)1 JFormattedTextField (javax.swing.JFormattedTextField)1 AbstractFormatterFactory (javax.swing.JFormattedTextField.AbstractFormatterFactory)1 InternationalFormatter (javax.swing.text.InternationalFormatter)1