0

How do I allow the display to show numbers with the commas, but then when it does the calculations, have the commas go away for the math since obviously java can't read commas in calculations?
example

DecimalFormat df0 = new DecimalFormat("###,###.00");
JFormattedTextField loanText = new JFormattedTextField(df0);

the user puts a number in say 500000, and when the user goes to the next TextField, it automatically sets the loanTextField to 500,000 since I told it to.

When the program takes those TextFields and grabs the number 500,000 - it reverts the number back to 500000 so it can read it?

I tried using the

loanText.replace(",", "");

but that only works with a String, not a JFormattedTextField

anyone?

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by JamesCherrill
1

You can leave the text field as it is and fix the commas after you read the text into your program, ie
String textWithoutCommas = loanText.getText().replace(",", "");

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.