java - Get user object in the selected row when TableRowSorter is clicked -
i using table model handle data in table. in that,
i use arraylist<myuserobject>datalist
hold data of model. i'm retriving user object using following method in model:
public myuserobject getmyuserobject(int rowindex) { return datalist.get(rowindex); }
so when row of table got selected i'm able index of selected row listselectionlistener
using datatable.getselectedrow()
, using value i'm able retrieve user object model using above method.
but when tablerowsorter used i'm unable actual value of user object in selected row. because when tablesorter clicked row index of data changed. in model remains unchanged. i'm unable correct user object regarding selected row.
in other words, row order changes in table should reflected in model.
should rearrange arraylist in model? or there other easy ways that?
how can resolve problem?
i'm able index of selected row
then need convert index model row:
int modelrow = table.convertrowindextomodel(selectedrow);
Comments
Post a Comment