Results 1 to 5 of 5

Thread: TableFormBuilder, dobule precision?

  1. #1
    Join Date
    Jan 2007
    Posts
    20

    Default 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. #2
    Join Date
    Jan 2006
    Location
    Vilnius, Lithuania
    Posts
    68

    Default

    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

  3. #3
    Join Date
    Jan 2007
    Posts
    20

    Default

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

  4. #4
    Join Date
    Jan 2006
    Location
    Vilnius, Lithuania
    Posts
    68

    Default

    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

  5. #5
    Join Date
    Apr 2010
    Posts
    8

    Smile how integer goes?

    Quote 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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •