Java-在JTable单元格中禁用科学计数法 [英] Java - Disable scientific notation in JTable cells
问题描述
我有一个JTable,其中显示了一系列Float.对于较小的值,该单元格以科学计数法显示数字.有办法禁用它吗?
I have a JTable where a series of Float are displayed. For small values the cell displays the number in scientific notation. Is there a way to disable that?
推荐答案
You should read the following page to get an insight about why it is happening: http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#editrender
然后,您应该将自己的NumberFormat
实例(以某种方式)传递到您的JTable
中,然后所有数字都将正确格式化.
Then you should pass your own NumberFormat
instance (somehow) in to your JTable
, and then all numbers will be formatted properly.
如果您决定长时间使用它,我认为通读整个JTable
文档是一本好书,并且我确信在那里提到了如何应用NumberFormat
.
I think it's a good read to read through the entire JTable
documentation if you decide to work with it for a long time and I am sure that it is mentioned there how to apply the NumberFormat
.
这篇关于Java-在JTable单元格中禁用科学计数法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!