I have a swt tree for which I have added SWT.EraseItem listener in order to get the selection, hover color for tree items. The selection, hover colors are appearing properly but that color is getting applied only till the text. I want it to get applied to the entire row.
Screenshot for your reference:

tree.addListener(SWT.EraseItem, new Listener() {
@Override
public void handleEvent(Event event) {
if ((event.detail & SWT.SELECTED) != 0 && (event.detail & SWT.MouseHover) != 0) {
int width = getBounds().width;
GC gc = event.gc;
gc.setForeground(new Color(Display.getCurrent(), 0, 0, 0));
gc.setBackground(new Color(Display.getCurrent(), 213, 215, 219));
gc.fillRectangle(0, event.y, width, event.height);
event.detail &= ~SWT.MouseHover;
event.detail &= ~SWT.SELECTED;
}
if ((event.detail & SWT.SELECTED) != 0 && !tree.isFocusControl()) {
int width = tree.getClientArea().width;
GC gc = event.gc;
gc.setForeground(new Color(Display.getCurrent(), 0, 0, 0));
gc.setBackground(new Color(Display.getCurrent(), 230, 232, 235));
gc.fillRectangle(0, event.y, width, event.height);
event.detail &= ~SWT.SELECTED;
}
if ((event.detail & SWT.MouseHover) != 0) {
int width = tree.getClientArea().width;
GC gc = event.gc;
gc.setForeground(new Color(Display.getCurrent(), 0, 0, 0));
gc.setBackground(new Color(Display.getCurrent(), 213, 215, 219));
gc.fillRectangle(0, event.y, width, event.height);
event.detail &= ~SWT.MouseHover;
}
if ((event.detail & SWT.SELECTED) != 0) {
int width = tree.getClientArea().width;
GC gc = event.gc;
gc.setForeground(new Color(Display.getCurrent(), 0, 0, 0));
gc.setBackground(new Color(Display.getCurrent(), 192, 235, 237));
gc.fillRectangle(0, event.y, width, event.height);
event.detail &= ~SWT.SELECTED;
}
Color previousForegroundColor = event.gc.getForeground();
event.gc.setForeground(previousForegroundColor);
}
});