JTable How to add a row between rows

后端 未结 1 1801
忘了有多久
忘了有多久 2021-01-29 10:07

I\'ve been looking for this quite a long time before and I can\'t find any question about this nor topic, I am assuming it might be impossible to do, though it seems odd as the

相关标签:
1条回答
  • 2021-01-29 10:27

    Use a DefaultTableModel <- see docs more contructors

    DefaultTableModel model = new DefualtTableModel(String colNames, int rows);
    JTable table = new JTable(model);
    

    Then you can use one of the following methods

    • DefaultTableModel#insertRow(int row, Object[] rowData) - Inserts a row at row in the model. The new row will contain null values unless rowData is specified. Notification of the row being added will be generated.

    Or

    • DefaultTableModel#insertRow(int row, Vector rowData) - Inserts a row at row in the model. The new row will contain null values unless rowData is specified. Notification of the row being added will be generated.

    0 讨论(0)
提交回复
热议问题