TableSorter.java
I read up on 'How to Use Tables'. I am using the TableSorter.java helper class from: http://java.sun.com/docs/books/tutorial/uiswing/components/table.html and have a small question regarding that. If I wanted to sort my JTable only from the second row onwards and leave the first row alone, how would I do that? The reason for me leaving out the first row is that I have provided the first row for the user to type in search parameters. I do not want the sorting function to mess with that row. I am using TableSorter.java as it is and ofcourse it is taking the empty cells of the first row into consideration and sorting those also. I do not want the TableSorter.java to consider the first row. I tried tweaking the TableSorter.java but to now avail. I was wondering if somebody used TableSorter.java before and had success in tweaking the code? Thanks in advance.
The way that I am using it right now..
TableSorter sorter = new TableSorter(tblOrders.getModel());
tblOrders.setModel(sorter);
sorter.setTableHeader(tblOrders.getTableHeader());
I went into TableSorter.java itself and tried to tweak this part of the code but it breaks..:(.
private Row[] getViewToModel() {
if (viewToModel == null) {
int tableModelRowCount = tableModel.getRowCount();
System.out.println("ROW COUNT : " + tableModelRowCount);
viewToModel = new Row[tableModelRowCount];
for (int row = 1; row < tableModelRowCount; row++) {
viewToModel[row] = new Row(row);
}
if (isSorting()) {
Arrays.sort(viewToModel);
}
}
System.out.println("viewToModel has : " + viewToModel.length);
return viewToModel;
}
I changed from int row = 0; to int row = 1;
cheers,
Misty.

