java - How to change the foreground color of specific items in a List? -
when press button, want change foreground color of selected item in list . so far, tried this: list.setforeground(display.getsystemcolor(swt.color_red)); but changes foreground color of items, not selected one. any ideas how solve this? doing list require custom drawing. better off using table instead (or tableviewer depending on requirements). here example of table want: public static void main(string[] args) { final display display = new display(); shell shell = new shell(display); shell.setlayout(new gridlayout(1, false)); shell.settext("stackoverflow"); final table table = new table(shell, swt.border | swt.multi); table.setlayoutdata(new griddata(swt.fill, swt.fill, true, true)); (int = 0; < 10; i++) { tableitem item = new tableitem(table, swt.none); item.settext("item " + i); } button button = new button(shell, swt.push); button.settext("color selected"); ...