Announcement Announcement Module
Collapse
No announcement yet.
TableFormBuilder, dobule precision? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • TableFormBuilder, dobule precision?

    Hey,
    I'm using a TableFormBuilder to, well, build a form. Now everything works great, except a double field.
    formBuilder.add("price"); adds a JTextField, but with only three digits after the dot (say 1.234, instead of 1.2345..). How can I change that?

    --
    Regards,
    Kornel

  • #2
    Take a look at org.springframework.richclient.form.binding.swing. NumberBinder from spring-rich-sandbox. It uses a BigDecimalTextField that can control number entry and format nicely. There are usage examples in NumberBinder JavaDocs. Configure the binder in your application context, and then add that binder to binder selection strategy.

    cheers,

    Andrius

    Comment


    • #3
      ok. Thank you, it worked. But is it also possible for simple types like double (not java.lang.Double)?

      Comment


      • #4
        No, I don't think Spring Rich supports binding primitives, as primitives cannot be held in ValueModels. However, if you are using Java 1.5 or later (I do), autoboxing would automatically convert between double and java.lang.Double, for example.

        BTW, storing quantities like price in double-typed variables is not a good idea, you'll get problems with rounding. It is better to use BigDecimal for monetary calculations :-)

        Andrius

        Comment


        • #5
          how integer goes?

          Originally posted by Kornel View Post
          Hey,
          I'm using a TableFormBuilder to, well, build a form. Now everything works great, except a double field.
          formBuilder.add("price"); adds a JTextField, but with only three digits after the dot (say 1.234, instead of 1.2345..). How can I change that?

          --
          Regards,
          Kornel
          hi

          i use tablebinder.add("level") to bind a integer property

          then throw a exception "java.lang.InstantiationError: org.springframework.binding.convert.ConversionExec utor"

          how can i bind a integer property to a proper component ?

          thank you!

          Comment

          Working...
          X