my dog learned polymorphism*
The moose likes Swing / AWT / SWT and the fly likes Retrieving DefaultTableModel from JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Retrieving DefaultTableModel from JTable" Watch "Retrieving DefaultTableModel from JTable" New topic
Author

Retrieving DefaultTableModel from JTable

Hewa Naimanage Sumedha Amalka
Greenhorn

Joined: Oct 31, 2006
Posts: 19
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


SCJP 1.4 71%, SCWCD 1.5 84%, SCBCD 90%, SCMAD 98%
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4642
    
    5

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.


luck, db
There are no new questions, but there may be new answers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Retrieving DefaultTableModel from JTable