tags:

views:

45

answers:

2

I have a JTable with a doubles column. Most of them are of the form x.xxx. Some of them end with a 0 and that is omitted, so I have a right-aligned table that looks like

1.339
 1.34
1.353
...

Any way to pad 0s to the end of it, or make it align by decimal place, or anything along those sorts? I would just assign them to strings and pad 0s that way, but then I would have the problem of String comparison (1 < 15 < 2 < 25 < 3).

+1  A: 

I think a custom TableCellRenderer might be what you want.

Here's an example from Google:

http://www.exampledepot.com/egs/javax.swing.table/CustRend.html

You should be able to modify it for your needs.

fd
+1  A: 

you can use a renderer as suggested by fd, theres an example here

objects