Bonsoir

J'aimerais pour colorier certaine cellule de mon JTable en focntion de la valeur qu'il y a dans cette cellule.

J'ai fait un renderer qui me semble correcte, je l'ai associer à la table, mais les couleur ne s'affiche pas :

Pour info :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 
public Component getTableCellRendererComponent(JTable table, Object value,
                                                 boolean isSelected,
                                                 boolean hasFocus, int row,
                                                 int column) {
    this.setText((String)table.getModel().getValueAt(row,column));
    int mergedColumn = table.getColumnModel().getColumnCount()-1;
    if(column == 1)
      System.out.println("hello");
    if( mergedColumn == column)
      this.setBackground(Color.ORANGE);
    else if(table.getModel().getValueAt(row,column).equals(table.getModel().getValueAt(row,mergedColumn)))
      this.setBackground(Color.GREEN);
    else this.setBackground(Color.RED);
    this.setForeground(Color.BLACK);
    return this;
  }
 
Association au jtable : 
 
jtable.setDefaultRenderer(Color.class, new TabCellRenderer());
Merci d'avance pour votre aide.