java - How can I resort (RowSort) after an insert in JTable? -


i know: how can reorder (re-sort) jtable rows after insert row?

i use next code:

tablemodel model = new defaulttablemodel(rows, columns) {   public class getcolumnclass(int column) {     class returnvalue;     if ((column >= 0) && (column < getcolumncount())) {       returnvalue = getvalueat(0, column).getclass();     } else {       returnvalue = object.class;     }     return returnvalue;   } }; jtable table = new jtable(model); rowsorter<tablemodel> sorter = new tablerowsorter<tablemodel>(model); table.setrowsorter(sorter); jscrollpane pane = new jscrollpane(table); 

this code works fine, , can add new rows without problem, want after insert new row re-sorts again using first column asc...

if want real time updates, try calling tablerowsorter#setsortsonupdates on tabkerowsorter , pass true...

otherwise, if want control when updates sorted, call tablerowsorter#sort

if want modify sort order programically, take @ sorting , filtering has example


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -