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) enter image description here

but after sorting columns row indices doesnt change.(1st, 2nd , 15th rows red again) enter image description here 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

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -