bunwong
asked on
How to display a Float with the format 0.0000 in a JTable?
I have a JTable displaying values for a Float data type. I would like to have the numbers displayed to 4 decimal points. e.g:
1.7 should be 1.7000
1 should be 1.0000
1.23456 should be 1.2346
But I don't know how to format display in a JTable cell. A few hours of doc digging did not help.
Is there any simple way to do it?
Thank!
Bun
1.7 should be 1.7000
1 should be 1.0000
1.23456 should be 1.2346
But I don't know how to format display in a JTable cell. A few hours of doc digging did not help.
Is there any simple way to do it?
Thank!
Bun
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, I'm all set now.
Please try this code
NumberFormat myformat = NumberFormat.getInstance()
myformat.setMaximumFractio
myformat.setMinimumFractio
System.out.println(myforma
or
use this code
float f=1.7f;
System.out.println(new DecimalFormat("#########.0
Hari