Here you can find the source of addNewRow(int index, JTable table, DefaultTableModel tableModel)
public static void addNewRow(int index, JTable table, DefaultTableModel tableModel) throws Exception
//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); } }