java - Sort JTable Except for Last Row -
i have jtable
last row total row aggregates other rows. when user clicks column header on table, rows sorted column, except total row should @ bottom.
is there simple way implement tablerowsorter
?
the following solution worked me....
in table model update getrowcount()
member return 1 row less required.
then modify index , row counts reported sorter follows...
tablerowsorter<tablemodel> sorter = new defaulttablerowsorter<tablemodel>(this.getmodel()) { public int convertrowindextomodel(int index) { int maxrow = super.getviewrowcount(); if (index >= maxrow) return index; return super.convertrowindextomodel(index); } public int convertrowindextoview(int index) { int maxrow = super.getmodelrowcount(); if (index > maxrow) return index; return super.convertrowindextoview(index); } public int getviewrowcount() { return super.getviewrowcount() + 1; } }; mytable.setrowsorter(sorter);
Comments
Post a Comment