File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes double Type of Value in JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "double Type of Value in JTable" Watch "double Type of Value in JTable" New topic
Author

double Type of Value in JTable

kirtesh jain
Ranch Hand

Joined: Nov 15, 2008
Posts: 44
hi...
for my table i have defined the table model in which one class type of column id double...so when i travels through the table and reach to that column when i press any digit ex:5 then it displays directly 0.05 instead of 5 .
how can i solve this problem please help...
thank you.
Andre Uhres
Greenhorn

Joined: Nov 23, 2008
Posts: 23
Try specifying default values null instead of 0.
kirtesh jain
Ranch Hand

Joined: Nov 15, 2008
Posts: 44
thanks for reply
but sir how we can apply null to double type variable...
thank you
Andre Uhres
Greenhorn

Joined: Nov 23, 2008
Posts: 23
One way is using setValueAt:
kirtesh jain
Ranch Hand

Joined: Nov 15, 2008
Posts: 44
sir it is giving null pointer exception....
kirtesh jain
Ranch Hand

Joined: Nov 15, 2008
Posts: 44
Which is the another way please help me out...
thank you.
Mikko Kohtamäki
Ranch Hand

Joined: Dec 13, 2008
Posts: 112
So you should handle these 'null' type values in your model if nesessary.

JTable has its own Double renderer (uses DecimalFormat for its display value) and if value is 'null' then it displays as a blank cell.

Or create your own TableCellRenderer and you can handle these 'null' values and you can set renderer's (eg. JLabel) diplaying value with help of DecimalFormat.
kirtesh jain
Ranch Hand

Joined: Nov 15, 2008
Posts: 44
ok thank you all... what i did is i am reading as string only and then converted into double and my problem got solved...
Thank You...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: double Type of Value in JTable