Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

double Type of Value in JTable

 
kirtesh jain
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try specifying default values null instead of 0.
 
kirtesh jain
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for reply
but sir how we can apply null to double type variable...
thank you
 
Andre Uhres
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One way is using setValueAt:
 
kirtesh jain
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sir it is giving null pointer exception....
 
kirtesh jain
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which is the another way please help me out...
thank you.
 
Mikko Kohtamäki
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic