private JFormattedTextField getCurrencyJFormattedTextField() {
NumberFormat format= NumberFormat.getNumberInstance();
format.setMaximumFractionDigits(4);
NumberFormatter formatter= new NumberFormatter(format);
formatter.setMinimum(0.0);
formatter.setValueClass(Double.class);
JFormattedTextField formattedTextField = new JFormattedTextField(formatter);
return formattedTextField;
}
So, if I explicitly key in "1.23456789"
UI of JFormattedTextField will show "1.2346"
However, when call getValue
, the returned value is 1.23456789
, not 1.23461
final double price = (Double)jFormattedTextField.getValue();
Is there any way to WYSIWYG? So that the underlying data structure will be consistence with UI display?