I have the following code:
public test() {
setLayout(new FlowLayout());
JFormattedTextField price = new JFormattedTextField(new DecimalFormat("#,##0.00 \u00A4"));
price.setValue(new Float(105.00));
add(price);
add(new JButton("Ok"));
pack();
setVisible(true);
}
If I enter a number now, for example ’20’. The textfield enters ‘105.00’ again.
Why it doesn’t accept my entry and always goes back to the default value?
there are three ways starting with easiest, ending with useless, maybe nonsense in comparing with points 1st and 2nd.
NumberFormat.getCurrencyInstance();orNumberFormat.getCurrencyInstance(Locale);forCurrency symbol, then this value is valid for concreteJTextField/JFormattedTextField/JSpinner/XxxCellRenderer/XxxCellEditor,code
.
NavigationFilter, fixed possition could be on the start or ending for possition (Bias) inJTextField/JFormattedTextField/JSpinner/XxxCellRenderer/XxxCellEditor,code
.
InputMaskwithInputVerifier, workaroung could / couldn’t be different for (each of)JTextField/JFormattedTextField/JSpinner/XxxCellRenderer/XxxCellEditor,