What I want to do is: Color the rows of a table where the cell in column x has a value present in an arraylist.
In more detail:
I fill the array list with the values 1000000, 1000001, 1000007
of a query to the database.
Now, I go through all the rows in column x and, if the value they have is equal to one of the ones in the arraylist, then it is colored.
It sounds easy, but I can not get the cells painted with these values, only the cell where the index of the arraylist is the most is colored (high in this case 2 or 1000007)
Code:
public static class solic_proc extends DefaultTableCellRenderer{
@Override
public Component getTableCellRendererComponent(JTable table, Object value,boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table,value,isSelected,hasFocus,row,column);
int i=0;
for(i=0; i<lista.size(); i++){
if(table.getValueAt(row, 0).toString().equals(String.valueOf(lista.get(i)))){
setBackground(Color.GREEN);
}else{
setBackground(new Color(255,255,255));
setForeground(new Color(1,70,148));
}
}