Images in 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

Images in controls

Postby kames » Thu Sep 25, 2008 2:24 am

Hi

I have a following problem. I've created a library in eclipse (java project, not a plug-in) with some controls, and some of those controls have images. I've used the following method to get the images:

Code: Select all
_lblRadioButtonReadOnlyImageSelected.setImage(SWTResourceManager.getImage("icons/RadioButtonReadOnlySelected.png"));


this method works when i test this library from inside of this project, but when I try to use it in some other Eclipse Plug-in project, the images are not loaded. I tried also to use the following method:

Code: Select all
_lblRadioButtonReadOnlyImageSelected.setImage(SWTResourceManager.getImage(this.getClass(), "icons/RadioButtonReadOnlySelected.png"));


but it doesn't work neither in this Controls project, nor in the eclipse plug-in project, no matter how many "../" i put before the path. Any idea how to make this work?

KameS
kames
 
Posts: 6
Joined: Thu Aug 21, 2008 4:46 am

Re: Images in controls

Postby Eric Clayberg » Thu Sep 25, 2008 11:12 am

The "icons" folder is not included in classpath of plugin, so you can not use the ClassLoader to access them.

Use ResourceManager.getPluginImage() instead (use our Image property editor to select the image to know how to use it correctly).
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

Re: Images in controls

Postby kames » Fri Sep 26, 2008 5:57 am

Hi,

I've done like you've said, but it still doesn't work. It works in the designer, but when I run it, it does not

KameS
kames
 
Posts: 6
Joined: Thu Aug 21, 2008 4:46 am

Re: Images in controls

Postby Eric Clayberg » Fri Sep 26, 2008 6:04 am

Send us a complete test case.
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


Return to SWT Designer

Who is online

Users browsing this forum: No registered users and 2 guests