How can a make my jface tableviewer display a chosen background color for specific rows? I have a timestamp in each row and like to give a row thats timestamp is on a monday a color, different than the others.
With ColumnLabelProvider it is even easier:
col.setLabelProvider(new ColumnLabelProvider() {
@Override
public Color getBackground(final Object element) {
if (element instanceof YourClass) {
if (((YourClass) element).shouldBeRed()) {
return new Color(Display.getDefault(), 0xFF, 0xDD, 0xDD);
}
}
return super.getBackground(element);
}
});
Of course you should not create new colors on each getBackground but use resource managers for that purpose.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With