Example usage for javax.swing.text NumberFormatter NumberFormatter

List of usage examples for javax.swing.text NumberFormatter NumberFormatter

Introduction

In this page you can find the example usage for javax.swing.text NumberFormatter NumberFormatter.

Prototype

public NumberFormatter() 

Source Link

Document

Creates a NumberFormatter with the a default NumberFormat instance obtained from NumberFormat.getNumberInstance().

Usage

From source file:org.springframework.richclient.form.FormatterFactory.java

public AbstractFormatter getFormatter(JFormattedTextField source) {
    Object value = source.getValue();
    DefaultFormatter formatter;/*from w ww .j a v a 2 s  .c  o  m*/
    if (value instanceof Date) {
        formatter = new DateFormatter();
    } else if (value instanceof Number) {
        formatter = new NumberFormatter();
    } else {
        formatter = new DefaultFormatter();
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Factory returning new formatter " + formatter + " for text field " + source);
    }
    valueCommitPolicy.configure(source, formatter);
    if (valueClass != null) {
        formatter.setValueClass(valueClass);
    } else if (value != null) {
        formatter.setValueClass(value.getClass());
    }
    return formatter;
}