How to clear contents of a jTable ?

前端 未结 8 2287
梦如初夏
梦如初夏 2020-12-05 05:41

I have a jTable and it\'s got a table model defined like this:

javax.swing.table.TableModel dataModel = 
     new javax.swing.table.DefaultTableModel(data, c         


        
8条回答
  •  悲哀的现实
    2020-12-05 06:04

    I think you meant that you want to clear all the cells in the jTable and make it just like a new blank jTable. For an example, if your table contains 40 raws, you can do following.

    DefaultTableModel model = (DefaultTableModel)this.jTable.getModel();
    model.setRowCount(0);
    model.setRowCount(40);
    

提交回复
热议问题