• Post Reply Bookmark Topic Watch Topic
  • New Topic

Q: Problem for getting Float objects from a JTable with a TableModel containing mixed object types  RSS feed

 
Charles Van Damme
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a good day.

I have troubles with a little 'totals' table with TableModel, containing String and Float objects in different cells.


And in the 'private void initGuiComponents(...)' method of my main file:

The GUI doesn' display its componets anymore + the compilation output screen of my NetBeans IDE installation mentions:
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Float
at ....MonModeleDeTableInfer.getValueAt(MonModeleDeTableInfer.java:70)


Why do I get a
"java.lang.String cannot be cast to java.lang.Float"

for a cell initialized with a Float
= new Float((float) 0.0f);
?
What's the correct syntax to recover the Float ?

Thanks for any answer
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!