Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retrieving DefaultTableModel from JTable

 
Hewa Naimanage Sumedha Amalka
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, I need to get DefaultTableModel from my exsiting Jtable; I am using Java 5.0 and when I use

DefaultTableModel model = (DefaultTableModel)dataTable.getModel();

sends me a
java.lang.ClassCastException
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you need the table to have a DefaultTableModel, either construct it with a DefaultTableModel or setModel to a DefaultTableModel.

If the table's model isn't a DefaultTableModel, you can't cast it as such.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic