【问题标题】:GWT - DoubleBox with more than 3 decimal placesGWT - 多于 3 位小数的 DoubleBox
【发布时间】:2012-09-03 09:57:54
【问题描述】:

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

正常吗?

什么是最好的解决方案?

谢谢。

【问题讨论】:

    标签: gwt double truncate


    【解决方案1】:

    正如 javadoc 所说,DoubleBox 是使用 DoubleParser 和 DoubleRenderer 的 ValueBox。这些依赖于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 模式(或者使用 DoubleParser 或创建自己的 Parser 和您的自定义 NumberFormat 模式)

    【讨论】:

    • 这样做比仅仅使用 TextBox 方法有什么优势?
    • 封装(将行为封装到小部件中),与编辑器框架集成。
    猜你喜欢
    • 2015-08-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多