Re: JTable and Double values

Discussion in 'Java' started by Manish, Jul 4, 2003.

  1. Manish

    Manish Guest

    I think I found the problem.
    JTable uses static inner class DoubleRenderer which uses NumberFormat
    instance internally to format the number and this number formatter rounds
    the number. BAD!

    Looks like I'll need to have my own custom cell renderer just to display my
    value as it is!!!! Don't you agree that this in fact should have been the
    default behaviour?

    - Manish

    "Manish" <> wrote in message
    news:be3hmi$q88p$...
    > The cells in my JTable rounds the double values. So 0.00276971 becomes
    > 0.003 (The precision is imporrtant here) How can I instruct the JTable to
    > not to round the double values? I know I can have a custom cell renderer,
    > but I prefer not doing it unless there is no other way. I have a feeling
    > that there must be some way of specifying this behaviour. In fact, I think
    > the exact representation of values shoud be the default behaviour and
    > rounding should be optional, but then it is just "my" opinion.
    >
    > TIA,
    > - Manish
    >
    >
    Manish, Jul 4, 2003
    #1
    1. Advertising

  2. Manish

    Jacob Guest

    Manish wrote:
    > I think I found the problem.
    > JTable uses static inner class DoubleRenderer which uses NumberFormat
    > instance internally to format the number and this number formatter rounds
    > the number. BAD!


    As a rule of thumb, always supply your own renderer
    (and table model and editor). The JTable defaults
    are more like "reference" implementations, and are
    more than good enough to prove the concept.
    Jacob, Jul 4, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tivo Escobar
    Replies:
    1
    Views:
    7,277
    manusa
    Apr 12, 2007
  2. Jason
    Replies:
    1
    Views:
    1,510
    Andrew Hobbs
    Feb 24, 2004
  3. Sydex
    Replies:
    12
    Views:
    6,455
    Victor Bazarov
    Feb 17, 2005
  4. Tintin92
    Replies:
    1
    Views:
    1,677
    Andrew Thompson
    Feb 14, 2007
  5. Haircuts Are Important
    Replies:
    3
    Views:
    302
    Haircuts Are Important
    Jun 4, 2013
Loading...

Share This Page