• Post Reply Bookmark Topic Watch Topic
  • New Topic

ClassCastException in DefaultTableModel sort

 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to sort columns using the Collections class on a custom table model that extends DefaultTableModel and implements Comparator. However, I keep getting a ClassCastExcption when the following runs in the compare method:

It seems like it doesn't like me trying to cast an Object(v1) to a Vector??
I should be able to do that, shouldn't I ?
Is this the case, or should I be looking for something else?
v1 is the dataVector from the DefaultTableModel that gets passed to the compare method.
BTW, this is my first time trying to use the Comparator interface, so bear with me. Please Let me know if I need to post anymore code.
Any help would be greatly appreciated!
Thanks!
[ March 22, 2004: Message edited by: Jennifer Sohl ]
 
Billybob Marshall
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.out.println("v1 is of type:" + v1.getClass());
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
v1 is a type of Object.
Don't know if this helps, here's the sort methods:

Also, from this code, at what point does the compare method get called from the Comparator interface?
Thanks again!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!