Color row where cell has value of arraylist

1

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));
     }

} 
    
asked by Germán 23.05.2017 в 03:57
source

1 answer

0

Add the break line; after the setBackground (Color.GREEN); so that it leaves the for at the time of coloring and do not continue evaluating all the values of the array.

    
answered by 24.05.2017 / 06:08
source