Author: Zafir Anjum
Note that if you are using your own subclass of AbstractTableModel(), this doesn't apply to you. Your TableModel should provide such a feature.
Here's the code snippet you can use to insert a blank row at the end of the table.
if( table.getModel() instanceof DefaultTableModel )
{
int cols = table.getModel().getColumnCount();
((DefaultTableModel)table.getModel()).addRow(new Object[cols]);
}
In the code above, we make a check whether the table model is an instance of a DefaultTableModel. This is required because when you create JTable giving it initial data, Swing creates an anonymous subclass of AbstractTableModel.
If you are using your own TableModel, make sure that addRow() is supported.
Posted On: 25-Feb-1999