GWT - 具有3位小数位数的DoubleBox [英] GWT - DoubleBox with more than 3 decimal places

查看:299
本文介绍了GWT - 具有3位小数位数的DoubleBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用GWT创建一个用户界面,并且有许多双重值,但是当我设置一些包含超过3个小数位的变量时,我的DoubleBox不接受并截断只有3个位置的数字。



是否正常?



最好的解决方案是什么?



谢谢。

解决方案

由于javadoc说 DoubleBox 一个 ValueBox 使用 DoubleParser DoubleRenderer 。那些依赖于 NumberFormat.getDecimalFormat(),它将在大多数(如果不是全部)区域设置中以3位小数中继(对于默认语言环境: http:// code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/gwt/i18n/client/constants/NumberConstantsImpl.properties



如果您想要另一种格式,请使用 ValueBox NumberFormatRenderer 与您的自定义 NumberFormat pattern(并使用 DoubleParser 或自己创建 Parser 与您的自定义 NumberFormat 模式)


I'm creating an user interface using GWT and there're many boxes of double values but when I set some variable which contains more than 3 decimal places my DoubleBox doesn't accept and truncates the number letting just 3 places.

Is it normal?

What's the best solution?

Thank you.

解决方案

As the javadoc says DoubleBox is a ValueBox using a DoubleParser and DoubleRenderer. Those rely on NumberFormat.getDecimalFormat() which will trunk at 3 decimals in most (if not all) locales (for the default locale: http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/gwt/i18n/client/constants/NumberConstantsImpl.properties)

If you want another format, then use a ValueBox with a NumberFormatRenderer with your custom NumberFormat pattern (and either use the DoubleParser or make your own Parser with your custom NumberFormat pattern)

这篇关于GWT - 具有3位小数位数的DoubleBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆