File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "SWT Composite setBackgroundImage() doesn Watch "SWT Composite setBackgroundImage() doesn New topic
Author

SWT Composite setBackgroundImage() doesn't support transparency?

Marcel Urbanek
Greenhorn

Joined: Aug 21, 2008
Posts: 1
Hi,

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
Greenhorn

Joined: Nov 22, 2008
Posts: 1
HI,

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

http://www.javafr.com/codes/SWT-CUSTOM-FILE-BROWSER_48514.aspx

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){
super(parent, SWT.TRANSPARENCE_ALPHA);}
}

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?