This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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
 
Similar Threads
how to use @hibernate.primitive-array xdoclet-tag
HibernateException - Wrong column type
Jtable mouse header cursor
JTable Trouble
Update Single value in a row