Java JTable Row Add addRowsToTable(Vector rows, int colCount)

Here you can find the source of addRowsToTable(Vector rows, int colCount)

Description

add Rows To Table

License

Open Source License

Declaration

public static DefaultTableModel addRowsToTable(Vector rows, int colCount) throws Exception 

Method Source Code

//package com.java2s;
/*//from   w ww .  java2s . c  o  m
 * 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 java.util.Vector;

import javax.swing.table.DefaultTableModel;

public class Main {
    public static DefaultTableModel addRowsToTable(Vector rows, int colCount) throws Exception {
        int rowCount = rows.size();
        //int rowsFromTM = tableModel.getRowCount();
        DefaultTableModel tableModel = new DefaultTableModel();
        //Vector headerValues = new Vector();

        /*for (int cnt = 0; cnt < rowsFromTM; ++cnt) {
         tableModel.removeRow(0);
         }*/
        tableModel.setColumnCount(colCount);
        for (int cnt = 0; cnt < rowCount; ++cnt) {
            String[] rowData = (String[]) rows.get(cnt);
            tableModel.addRow(rowData);

        }

        return (tableModel);
    }
}

Related

  1. addNewRow(int index, JTable table, DefaultTableModel tableModel)
  2. addRow(JTable table, Object... data)
  3. addRowToJTable(final JTable table, final Object[] data)
  4. addRowToTable(JTable table)
  5. appendRow(JTable table, Object[] row)