I am trying to sort my JTable by extending DefaultTableModel and overriding getColumnClass () as follows:
public Class getColumnClass(int c) { return getValueAt(0, c).getClass(); }
It works fine if there is no NULL in this cell. So I changed it as follows:
public Class getColumnClass(int c) { for(int rowIndex = 0; rowIndex < data.size(); rowIndex++){ Object[] row = data.get(rowIndex); if (row[c] != null) { return getValueAt(rowIndex, c).getClass(); } } return getValueAt(0, c).getClass(); }
Now, again, it works fine if at least one cell in the column is not NULL. But if all the cells in the column are NULL, this does not work ('casue returns nullPointerException).
Please ............ help .... thanks in advance
Hasan
Hasan source share