I’m creating a JSpinner and setting a NumberEditor with a custom format.
But no matter what I do the format uses “.” instead of “,”, not according to my locale (pt_BR).
priceSpinner = new JSpinner();
priceSpinner.setEditor(new JSpinner.NumberEditor(priceSpinner, "0.00"));
Is it possible to use “,” instead of “.” as a decimal separator?
By specifying a custom format pattern you are telling the JRE to ignore your locale and use that specific format. If you are simply after a spinner for numbers to two decimal places, use setModel() instead of setEditor() which will create a NumberEditor for you:
If you absolutely must use your own format pattern, you can adjust the decimal format symbols for that pattern after you’ve created it: