Community
Participate
Working Groups
Formatting of numbers differs between locales. Sometimes a "," is used instead of a "." as the decimal separator. Sometimes thousands are separated by a " " and other times by a "," and so on. These formatting differences are known to java.text.NumberFormat. It would be very useful for the Spinner widget to incorporate some I18N facility that allows specification of a NumberFormat. This would also allow the Spinner to handle currency values and the like.
Spinner uses the correct decimal separator for the current locale, "." on english, "," in portuguese, etc. Are you asking API to set the decimal separator? For example, to force "," to be used instead of "." in English ?
> Are you asking API to set the decimal separator? For > example, to force "," to be used instead of "." in English ? No. Just the correct formatting for the current locale is fine. Does the existing behaviour mean that the "thousands" separator will also be correct for the current locale. eg. will one thousand two hundred thirty four appear as either "1234", "1 234" or "1,234" depending upon locale? Can I turn off "thousands" separators altogether? For me, the best solution would be one that allows me to specify an instance of java.text.NumberFormat that the Spinner will use to format its current value for display. eg. add the following to the spinner's api: public void setNumberFormat(java.text.NumberFormat format); Generally I would pass in the NumberFormat instances supplied by the getNumberInstance(), getPercentInstance() and getCurrencyInstance() factory methods of NumberFormat. With such a facility, I could use spinners to set percentages and currency values in an internationalizable way (both of which would be great in the SWT application I'm currently working on).
Sorry Rob, Spinner doesn't have thousands separator, only decimal separator (used when running on float point mode, by calling setDigits()).
I noticed the same deficiency of Spinner (in floating-point mode) as the OP. I think the needs are real: Quite often applications need to run in given locale, independent of the "native" or "natural" locale of the OS (which seems to fix the appearance of the decimal separator of the Spinner widget). For every observable UI elements I am aware of (Please correct me, if I am wrong), this is easily done by setting the applications's locale (via start parameters). Regrettably Spinner is an exception here. I propose one of the following options: 1) Take full local information of number formats into account (i.e. including thousand separator and others) and provide an getter/setter interface in Spinner which allows setting the NumberFormat or Locale. Although this seems the most complete solution it will cause backward-compatibility problems (at least if those are not viewed as bugs, which need fixing) 2) A minimum solution which would not seem to cause any harm would be the addition of a simple setter function namely void Spinner.setDecimalSeparator(char newSeparator); which conforms to the java.text.DecimalFormatSymbols interface.
see Bug 103127
Your bug has been moved to triage, visit http://www.eclipse.org/swt/triage.php for more info.