Home > Enterprise >  JFormattedTextField removes fraction part
JFormattedTextField removes fraction part

Time:09-17

Whenever I enter any number with a fraction for example 50.25 the fraction part gets removed to 50.00.

DecimalFormat decimalFormat = new DecimalFormat("#,##0.00");
NumberFormatter currencyFormatter = new NumberFormatter(decimalFormat);
currencyFormatter.setMinimum(0);

JFormattedTextField AmountField = new JFormattedTextField(currencyFormatter);

How can I fix it to accept fraction numbers?

CodePudding user response:

Changing setMinimum value solved the problem:

currencyFormatter.setMinimum(0.00);
  • Related