The main problem is that the column count is returning 0
from the TableModel's
super class DefaultTableModel
. You need to override this method
@Override
public int getColumnCount() {
return columnNames.length;
}
Another side but potentially fatal issue is the fact that getColumnClass
is returning the class of elements within the TableModel
. This will throw a NullPointerException
if the table is empty. Use a class literal instead such as String.class
.
Maintaining a separate backing data array is unnecessary for DefaultTableModel
. It has already has its own data vector. This approach is used when extending AbstractTableModel
.