• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

JTable  RSS feed

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to create a Jtable using Vectors. When I compile the code I get the following error. What is the cause of this error?
C:\j2sdk1.4.1_04\bin\dev\Table>java SimpleTableDemo
Exception in thread "main" java.lang.ClassCastException
at javax.swing.table.DefaultTableModel.justifyRows(DefaultTableModel.jav
a:238)
at javax.swing.table.DefaultTableModel.setDataVector(DefaultTableModel.j
ava:194)
at javax.swing.table.DefaultTableModel.<init>(DefaultTableModel.java:131
)
at javax.swing.JTable.<init>(JTable.java:392)
at SimpleTableDemo.<init>(SimpleTableDemo.java:29)
at SimpleTableDemo.main(SimpleTableDemo.java:70)
 
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of being a Vector of Appointments, the data Vector should be a Vector of Vectors of Strings. (Yes, read it again...)

To get the same data that you have specified into the table, you'd have to do something like this...

 
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's the error with DataVector you are passing as an argument to the constructor of DefaultDataModel.
The DefaultDataModel expects datavector being a Vector of Vectors in which
* Vector containing multiple Vectors(inner) resembling rows in a Table.
* The inner Vector contains elements resembling columns in each row.
 
VIJAY Yadlapati
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's the error with DataVector you are passing as an argument to the constructor of DefaultDataModel.
The DefaultDataModel expects datavector being a Vector of Vectors in which
* Vector containing multiple Vectors(inner) resembling rows in a Table.
* The inner Vector contains elements resembling columns in each row.
 
She said she got a brazillian. I think owning people is wrong. That is how I learned ... tiny ad:
global solutions you can do at home or in your backyard
https://www.kickstarter.com/projects/paulwheaton/better-world-boo
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!