• Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting classCastException while using DefaultTableModel

 
Sowmiya Selvamani
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I m using NetBeans5.5

When I run the below code I got the exception as




Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.lang.String
at javax.swing.table.DefaultTableModel.justifyRows(DefaultTableModel.java:242)
at javax.swing.table.DefaultTableModel.setDataVector(DefaultTableModel.java:198)
at javax.swing.table.DefaultTableModel.<init>(DefaultTableModel.java:133)
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DefaultTableModel's first Vector should contain Vectors that contain Strings, not contain the Strings themselves.

If you change

into

it should work.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!