How could I empty my JTable (AbstractTableModel)? If I run tableModel.deleteData();
, then the message "0 >= 0" appears. Thanks!
class QueryTableModel extends AbstractTableModel {
Vector cache; // will hold String[] objects
int colCount;
String[] headers;
String url; String databasename;
String login; String pass;
Connection db;
static Statement statement;
public QueryTableModel(String url, String databasename, String login, String pass) {
cache = new Vector();
initDB(url, databasename, login, pass);
}
public static Statement getStatement() {
return statement;
}
@Override
public String getColumnName(int i) {
return headers[i];
}
public int getColumnCount() {
return colCount;
}
@Override
public Class getColumnClass(int col) {
return getValueAt(0, col).getClass();
}
@Override
public int getRowCount() {
return cache.size();
}
@Override
public Object getValueAt(int row, int col) {
Object str = ((Object[]) cache.elementAt(row))[col];
if (str != null)
return str;
else return "";
}
public void deleteData() {
cache.clear();
fireTableChanged(null);
}
...
}