Remove all the rows from a DefaultTableModel - Java Swing

Java examples for Swing:JTable Model

Description

Remove all the rows from a DefaultTableModel

Demo Code


//package com.java2s;
import javax.swing.table.DefaultTableModel;

public class Main {
    /**//  w w  w . j  ava2s.c o  m
     * Remove all the rows from a DefaultTableModel
     *
     * @param modelo
     * @return
     */
    public static void removeAllRows(DefaultTableModel modelo) {
        int a = modelo.getRowCount();
        for (int i = 0; i < a; i++) {
            modelo.removeRow(0);
        }
    }
}

Related Tutorials