Java-在JTable单元格中禁用科学计数法 [英] Java - Disable scientific notation in JTable cells

查看:99
本文介绍了Java-在JTable单元格中禁用科学计数法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆