In a elipse-rcp application I am setting the background color for a row in a jface table but I don't want the selection to change this color. I want to be able to specify the color change for a selected row.
Thanks VonC. Using the code from the above example I was able to do what I wanted.
ks
2009-05-27 16:51:22
A:
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet129.java
may be helpful here
Ben Hammond
2009-05-26 20:57:47
+1
A:
table.addListener(SWT.EraseItem, new Listener() {
public void handleEvent(Event event) {
event.detail &= ~SWT.HOT;
if ((event.detail & SWT.SELECTED) == 0) return; /// item not selected
Table table =(Table)event.widget;
TableItem item =(TableItem)event.item;
int clientWidth = table.getClientArea().width;
GC gc = event.gc;
Color oldForeground = gc.getForeground();
Color oldBackground = gc.getBackground();
gc.setBackground(colorBackground);
gc.setForeground(colorForeground);
gc.fillRectangle(0, event.y, clientWidth, event.height);
gc.setForeground(oldForeground);
gc.setBackground(oldBackground);
event.detail &= ~SWT.SELECTED;
}
});
ks
2009-05-27 16:54:57
@ks: thank you for that feedback. +1. You could choose your own post as the official answer if you want
VonC
2009-05-27 17:33:56