select - swt table change selection item color -
i'm using standard swt table which, may know, default when item selected colored blue (windows standard). when selection inactive, turns light gray. override both colors... i've searched on web find old code no longer seems work table widget.
below sample code trying overwrite default color doesn't seem working (please excuse dirty code, trying 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 greaaatly massively appreciated :d
if want go tableviewer manage table, can use styledcelllabelprovider determine colors/fonts/etc individual cells. tableviewer take care of "owner draw" aspects you. biggest hassle setting contentprovider, labelprovider, , input classes go tableviewer.
Comments
Post a Comment