java - Coloring some rows in JXTable -
i have problem coloring rows after resorting columns. want coloring every row 4th column equals zero. have overridden preparerenderer() method this:
public component preparerenderer(tablecellrenderer renderer, int row, int column) { component comp = super.preparerenderer(renderer, row, column); int modelrow = convertrowindextomodel(row); int modelcolumn = convertcolumnindextomodel(column); double d = (double) getmodel().getvalueat(row, 4); if(d <= 1e-4){ comp.setforeground(color.red); }else{ comp.setforeground(color.black); } return comp; }
it works fine. (1st, 2nd , 15th rows colored red)
but after sorting columns row indices doesnt change.(1st, 2nd , 15th rows red again) how fix ?
double d = (double) getmodel().getvalueat(row, 4);
the data in model never sorted need use:
double d = (double) getmodel().getvalueat(modelrow, 4);
Comments
Post a Comment