FileDocCategorySizeDatePackage
DecimalField.javaAPI DocExample927Tue Dec 12 18:59:18 GMT 2000None

DecimalField

public class DecimalField extends JTextField

Fields Summary
private NumberFormat
format
Constructors Summary
public DecimalField(double value, int columns, NumberFormat f)

        super(columns);
        setDocument(new FormattedDocument(f));
        format = f;
        setValue(value);
    
Methods Summary
public doublegetValue()

        double retVal = 0.0;

        try {
            retVal = format.parse(getText()).doubleValue();
        } catch (ParseException e) {
            // This should never happen because insertString allows
            // only properly formatted data to get in the field.
            Toolkit.getDefaultToolkit().beep();
            System.err.println("getValue: could not parse: " + getText());
        }
        return retVal;
    
public voidsetValue(double value)

        setText(format.format(value));