Adding images to SWT Controls

SWT Designer allows you to create the views, editors, perspectives, pref pages, composites, etc. that comprise Eclipse SWT & RCP applications and plug-ins.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

Adding images to SWT Controls

Postby hkiewe » Tue Jan 03, 2006 3:16 pm

I am trying to add an image to various SWT Controls (MenuItem, Label, etc). I click "image" in the Properties Editor, then click the "…" icon. The Select image dialogue opens but no images appear in the list and clicking "OK" does nothing.

I have selected the "Relative to source folder" button and placed the image I want to use in my project folder, yet it does not appear on the list, even after I re-launched Eclipse with a -clean option.

I’m using a Window Builder 4.2.0 plugged into Eclipse SDK Version: 3.1.1 running on Windows XP Home.

How can I get this to work?
hkiewe
 
Posts: 2
Joined: Tue Jan 03, 2006 2:59 pm
Location: Montreal

Re: Adding images to SWT Controls

Postby Eric Clayberg » Tue Jan 03, 2006 8:29 pm

hkiewe wrote:I have selected the "Relative to source folder" button and placed the image I want to use in my project folder, yet it does not appear on the list, even after I re-launched Eclipse with a -clean option.

Does your project have a source folder (/src)? If your project uses a /src folder, your images need to be relative to that, not the root of your project.

Have you tried the "Relative to class" option?

hkiewe wrote:I’m using a Window Builder 4.2.0

Have you tried v4.2.1?
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Postby Kelly » Wed Jan 04, 2006 6:31 am

If you did not use Eclipse to add the images to your src directory then you need to do a refresh of that directory in the 'Package Explorer' view of Eclipse.

Right click on the src directory and select the 'Refresh' option in the popup menu.
Kelly
 
Posts: 38
Joined: Wed Feb 02, 2005 8:22 am

Re: Adding images to SWT Controls

Postby hkiewe » Wed Jan 04, 2006 9:20 am

Thank you Eric and Kelly,

I do not have a /src folder within my workspace. I refreshed my project in Package Explorer and now the graphic I placed there is visible and can be selected in the Select image dialogue.

However, it does it not appear in the widget, even when the GUI is previewed.

What should I do now?

I downloaded and installed 4.2.0 just before Christmas and wasn't aware of a 4.2.1 version. My evaluation license expires today and unfortunately I haven't had much of chance to try it out since I was off work over the holidays.

Howard
hkiewe
 
Posts: 2
Joined: Tue Jan 03, 2006 2:59 pm
Location: Montreal

Postby Kelly » Wed Jan 04, 2006 10:45 am

If the widget has text and/or the setText() method is placed after the setImage() method call then you will not see the image.

example:

label.setImage("image.png");
label.setText("MyLableText");

With the above you will not see an image either in the designer or running the program, reverse them and you will or remove the setText call.

This effect is caused by SWT not the designer, cause SWT widgets can only show text or an image not both unless you are running the WinXP theme and have the SWT 3.2.0 version library, so designer just did what you told it to do.
Kelly
 
Posts: 38
Joined: Wed Feb 02, 2005 8:22 am


Return to SWT Designer

Who is online

Users browsing this forum: No registered users and 1 guest