Java examples for Swing:JTable Model
Clean the JTable, only apply to DefaultTableModel
//package com.java2s; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableModel; public class Main { /**//from w w w . j av a2 s .co m * Clean the table, only apply to DefaultTableModel * * @param tableModel */ public static void removeAllRows(TableModel tableModel) { if (tableModel instanceof DefaultTableModel) { DefaultTableModel dtm = (DefaultTableModel) tableModel; dtm.setRowCount(0); } } }