Java JTable Row Add addNewRow(int index, JTable table, DefaultTableModel tableModel)

Here you can find the source of addNewRow(int index, JTable table, DefaultTableModel tableModel)

Description

add New Row

License

Open Source License

Declaration

public static void addNewRow(int index, JTable table, DefaultTableModel tableModel) throws Exception 

Method Source Code

//package com.java2s;
/*/*from  w  w w .  j  a  v a 2 s  .c  om*/
 * Id: 
 *
 * Copyright (C) 2004, Cladonia Ltd. All rights reserved.
 *
 * This software is the proprietary information of Cladonia Ltd.  
 * Use is subject to license terms.
 */

import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

public class Main {
    public static void addNewRow(int index, JTable table, DefaultTableModel tableModel) throws Exception {
        String[] row = new String[table.getColumnCount()];
        for (int cnt = 0; cnt < table.getColumnCount(); ++cnt) {
            row[cnt] = "Heading" + cnt;
        }
        tableModel.insertRow(index, row);
    }
}

Related

  1. addRow(JTable table, Object... data)
  2. addRowsToTable(Vector rows, int colCount)
  3. addRowToJTable(final JTable table, final Object[] data)
  4. addRowToTable(JTable table)