0

I intialize my JFormattedTextField like this :

JFormattedTextField field = new JFormattedTextField();
field.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0.00"))));

Now, when I enter any number with decimal points, the field returns a Double. When I enter a number without decimal points, it returns a Long. Is there a way to setup the Formatter so it returns a Double even when the number entered has no decimal points ?

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Jannis Alexakis
  • 1,279
  • 4
  • 19
  • 38

0 Answers0