How to clear contents of a jTable ?

前端 未结 8 2250
梦如初夏
梦如初夏 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 05:52

    You have a couple of options:

    1. Create a new DefaultTableModel(), but remember to re-attach any listeners.
    2. Iterate over the model.removeRow(index) to remove.
    3. Define your own model that wraps a List/Set and expose the clear method.

提交回复
热议问题