1

I am trying to add new row on the JTable when it saves the information to the database, it works for adding row to database. However, it doesn't work when I am trying to add row to the JTable.

DefaultTableModel table = (DefaultTableModel) jTable1.getModel();
jTable1.setModel(table);
table.addRow(new Object[]{TChampion.getText(),score,kill,death,asisst});

But, I got an error( I used try and catch):

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

TT.
  • 15,774
  • 6
  • 47
  • 88
user38543
  • 59
  • 3
  • You should include a [MCVE] so people can try to reproduce your problem. I do not see any problem with the short snippet you posted. – TT. Jul 02 '17 at 07:04
  • this basically all I have in the code – user38543 Jul 19 '17 at 19:27
  • Read this answer on SO: https://stackoverflow.com/a/10132017/243373. The take away: cast to `TableModel` instead of `DefaultTableModel`. – TT. Jul 19 '17 at 19:47

0 Answers0