org.jdesktop.swingbinding.JTableBinding$BindingTableModel cannot be cast to javax.swing.table.DefaultTableModel

后端 未结 2 1554
野性不改
野性不改 2021-01-24 09:00

I tried to group JTable header and for that I want to get the DefaultTableModel of current JTable. But when I tried to retrieve the table model like this:

Defaul         


        
2条回答
  •  南笙
    南笙 (楼主)
    2021-01-24 09:20

    According to the JavaDoc for BindingTableModel, the class doesn't extend DefaultTableModel. Rather, it implements TableModel interface. This means that you cannot cast to DefaultTableModel, only to TableModel:

    TableModel dm=(TableModel) tblTet.getModel();
    

提交回复
热议问题