Bonjour, j'utilise une table JXTable.
JE voudrais modifier la couleur de fond d'une ligne selon l'information contenue dans une colonne de la ligne.
Pour cela j'utilise une fonction de JTable, mais cela ne marche pas.
Pouvez vous m'aider, merci.
Mon code :
_studyListTable.setDefaultRenderer( Object.class, new MyTableCellRenderer() );
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| public MyTableCellRenderer() {
super();
System.out.println("Renderer");
}
public Component getTableCellRendererComponent(JXTable table,Object value, boolean isSelected, boolean hasFocus,
int row, int column) {
System.out.println(isSelected);
if(isSelected){
this.setBackground(Color.red);
}else{
this.setBackground(table.getBackground());
}
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
return this;
} |
Partager