java - Does there exist a fix / best-practice approach for sorting JTables with dynamic model -


i found the following question regarding sorting jtable whichs model not "static" elements may added it, automatically updating sort order. accepted answer states:

so, changed

firetablecellupdated(row, col);

to

firetablerowsupdated(0, data.size() - 1);

and sorts properly, upon data changes, , selection preserved.

since question on 5 years old, java 8 , co. happening, wanted ask if there new / better solution achieve sorting.

in model implementing abstracttablemodel call

firetablecellupdated(newrowid, newcolid); 

when new item added.

the code in ui looks following:

jtable table = new jtable(); table.setmodel(mymodel); // mymodel declared somewhere above table.setautocreaterowsorter(true); table.getrowsorter().setsortkeys(arrays.aslist(new rowsorter.sortkey(0, sortorder.ascending))); 

do have go solution proposed in other question or there "better" / best-practice way this?


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -