wood burning stoves
The moose likes Swing / AWT / SWT and the fly likes SWT Composite setBackgroundImage() doesn't support transparency? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "SWT Composite setBackgroundImage() doesn Watch "SWT Composite setBackgroundImage() doesn New topic

SWT Composite setBackgroundImage() doesn't support transparency?

Marcel Urbanek

Joined: Aug 21, 2008
Posts: 1

I'm trying to do the following:

A composite with background image contains a composite with a transparent background image which itself contains a label:

composite with background image->composite with transparent background image->label

The idea is, that the label inherits in first place the background of its parent composite, and in second place (where background is transparent) the background of the "root" composite.

But now it looks like SWT can't handle transparent background images for composites. The transparent section is replaced by white color instead of being transparent (at least under windows).

Now this is my question: Do I do something wrong or are transparent background images not supported by SWT? If so, is there a workaround?

Thanks in advance!
julien tixador

Joined: Nov 22, 2008
Posts: 1

I had the same problem, I created my own Icons, so needed a clickable image+text with transparent background. I did this:


there are 2 things:
1- shell.setBackgroundMode(SWT.INHERRIT_DFAULT);
to make all childrens hinerit from the shell background

2-Class MyIcon entends Composite{
MyIcon(Composite parent, int style){

It's very young but I draw my own Image in a Composite with a transparent background, so I see the background image of my shell.

Hope it can help
I agree. Here's the link: http://aspose.com/file-tools
subject: SWT Composite setBackgroundImage() doesn't support transparency?
It's not a secret anymore!