APS Excellence in Physics Education Award
November 2019

Education Prize Logo
Science SPORE Prize
November 2011

NSF Logo
The Open Source Physics Project is supported by NSF DUE-0442581.

Internationalization, decimal comma instead of dot. post and replies

Return to the Internationalization, decimal comma instead of dot. thread
Login to post to this thread

Decimal comma instead of dot.
Gustavo Rascioni
2 Posts

Hi all,
I have several number fields with the format: "0.###". But when I try to change it (even using the "Add language facilities" feature) to "0,###", I get the following error:
  Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at org.colos.ejs.library.control.swing.ControlNumberField.setValue(Unknown Source)
at org.colos.ejs.library.control.ControlElement.setProperty(Unknown Source)

I'd appreciate any help.
Thanks,
Gustavo


Replies to Decimal comma instead of dot.

Re: Decimal comma instead of dot. -
Francisco Esquembre
237 Posts

Gustavo,

The Format field requires a dot '.' and not a comma ','. The dot is used to indicate where the decimal part begins.

If you are using the Field element (it displays a "2.0" in its icon), this element displays decimal points using the English format, that is something like "3.1415". We need this because the element actually parses the value. So, you can enter expressions like "2.0*3.15" or even "2*pi".

The older - actually deprecated, but still usable- Field_old (which displays a "1.0" in its icon) is able to accommodate to the local language. Hence, this older element, for a given format like "0.###" would display "3.145" in an English computer and "3,145" in a Spanish computer. (To bring in deprecated - older- view elements, check the "Show panels of deprecated elements" in the "Aspect" tab of the EJS options dialog.)

That's the best we can do. But recall, no matter which element you use, you must specify the Format property using the correct syntax (which uses always a '.' ). Translation does not let you change the "0.000" to "0,000". You would translate to change, f.i.,  "Force = 0.00" to "Forza = 0.00".

Paco



Re: Re: Decimal comma instead of dot. -
Gustavo Rascioni
2 Posts

Thanks for replying so fast, Paco.

I understand the issue with the Format field now.
And yes, I'm using the new Field element, all over the place actually, so I'll have to consider if it is worth it to make the change and use the older one instead.
Also, apart from loosing the ability to enter complex expressions, is there any caveat on replacing the 2.0 Field with the 1.0 Field?

Again, thanks for your response.
Gustavo



Re: Re: Re: Decimal comma instead of dot. -
Francisco Esquembre
237 Posts

>Also, apart from loosing the ability to enter complex expressions, is there any caveat on replacing the 2.0 Field with the 1.0 Field?

Hum!... I can't think of any problem, no.

Paco



OSP Projects:
Open Source Physics - EJS Modeling
Tracker
Physlet Physics
Physlet Quantum Physics
STP Book