I am trying to create a SWT tree that has icons at the top level, but not at the next level.

Is there a way to avoid the empty space that seems to be left for the image that I am not using? I tried using the following code snippets but didnโt do what I wanted.
SWT.MeasureItem:
tree.addListener(SWT.MeasureItem, new Listener()
{
@Override
public void handleEvent(Event event)
{
TreeItem item = (TreeItem)event.item;
Image image = item.getImage();
if (image == null)
{
event.x -= 40;
}
}
});
SWT.PaintItem:
tree.addListener(SWT.PaintItem, new Listener()
{
@Override
public void handleEvent(Event event) {
TreeItem item = (TreeItem)event.item;
Image image = item.getImage();
if (image == null)
{
event.x -= 40;
}
}
});
In both cases, I just hoped that the text could be pulled a little to the left.
source
share