I found an example of using DefaultTableModel to sort by columns. I understand all except:
model = new DefaultTableModel(data, colnames) { public Class GetColumnClass (int column) { if(column >= 0 && column <= getColumnCount()) return getValueAt(0, column).getClass(); else return Object.class; } };
I'm assuming GetColumnClass is called by one of the constructors, or at least it ensures that there is method defined for it. If I comment out that section, I can still generate a table, and if I click on the column names I can sort the data. Is it necessary to define that method?