I use the standard swt table, which, as you know, by default, when an element is selected, it is colored blue (standard windows). When the selection is inactive, it turns light gray. I would like to override both colors ... I searched all over the network, but could only find very old code that no longer works with table widgets.
Below is an example of code that I tried to overwrite the default color, but it does not seem to work (please excuse the dirty code, just trying to get something to work):
table.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent event) { Color rowSelectionColor = new Color(Display.getCurrent(),new RGB(235, 200, 211)); TableItem item =(TableItem)event.item; item.setBackground(0,rowSelectionColor); item.setBackground(1,rowSelectionColor); item.setBackground(2,rowSelectionColor); } @Override public void widgetDefaultSelected(SelectionEvent event) { Color rowSelectionColor = new Color(Display.getCurrent(),new RGB(235, 200, 211)); TableItem item =(TableItem)event.item; item.setBackground(0,rowSelectionColor); item.setBackground(1,rowSelectionColor); item.setBackground(2,rowSelectionColor); } });
Any ideas would be greatly appreciated: D
source share