0

I have a JTable and I use binding (JTableBinding) to bind a list to it
In the object I use I have a getter and setter to each bind member.
This ofcourse is loaded with reflection.

My problem is that sometimes I get -0.0 instead of plain zero in the display. How can I format it to be alwayz 0 when it is -0.0? Thannks

trashgod
  • 203,806
  • 29
  • 246
  • 1,045
Bick
  • 17,833
  • 52
  • 146
  • 251
  • possible duplicate of [How can a primitive float value be -0.0? What does that mean?](http://stackoverflow.com/questions/6724031/how-can-a-primitive-float-value-be-0-0-what-does-that-mean) – Armen Tsirunyan Jul 17 '11 at 13:45
  • 1
    Same question was asked 10 minutes ago – Armen Tsirunyan Jul 17 '11 at 13:46
  • @Armen Tsirunyan: Almost identical, but here the question revolves around how to apply the [accepted answer](http://stackoverflow.com/questions/6724031/how-can-a-primitive-float-value-be-0-0-what-does-that-mean/6724051#6724051). – trashgod Jul 17 '11 at 19:06
  • Exactly. Didn't want to ask it in the comments and I thought it would assist to open new issue. – Bick Jul 20 '11 at 09:07

2 Answers2

1

I'm unfamiliar with JTableBinding, but a suitable implementation of TableCellRenderer may suffice. The relevant tutorial is here, and there's an example here.

trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • agreed http://stackoverflow.com/questions/6556651/jtable-cell-editor-number-format/6556681#6556681 (:- but hardcoded to instanceof.Double:-) +1 – mKorbel Jul 17 '11 at 14:49
0

add a special case to check if your float is 0 or -0 then print 0

Randy
  • 16,480
  • 1
  • 37
  • 55