Recent Changes - Search:





Format property for view elements displaying variables

The Format property of elements which display the value of a variable is a String that specifies how the value is formatted before being displayed.
The String you provide is passed to the constructor of the Java class java.text.DecimalFormat(String yourFormat);


The basics of this class state that you can provide a String like this: “0.00;−0.00” indicating that you want exactly two decimal places for the value, and a minus sign for negative numbers.
A variant of this is “0.##;−0.##” which means that you want a maximum of two decimal places, but that if the value is, say, 0.1, it should not be displayed as 0.10.


Finally, you can also add prefixes and suffixes to the format, such as “x = 0.00 meters;x = −0.00 meters”. This works very well for display, but be warned that if you try to modify the value of the variable by typing a new value, you must strictly respect the prefixes, suffixes, and even blank spaces in the format.


For a more complete reference of the java.text.DecimalFormal class, see the DecimalFormat javadoc reference page.

Edit - History - Print - Recent Changes - Search
Page last modified on December 05, 2010, at 11:50 AM