Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Problem with ToolItem image
Problem with ToolItem image [message #481696] Sun, 23 August 2009 17:47 Go to next message
B. Todorov is currently offline B. TodorovFriend
Messages: 8
Registered: July 2009
Junior Member
I create new tool item and set it Image from the hard drive. When I run
the application with Eclipse Web Browser everything is perfect(All tool
items have images). But when I run it in external browser(Firefox, IE) the
tool items are there, but have no images. I have also added all images to
the "Binnary build"

ToolItem toolItem = new ToolItem(toolBar, SWT.PUSH);
toolItem.setImage(ImageDescriptor.createFromURL("file:/E:/icons/image.png ").createImage());

Can anybody help me solve the problem?

Thanks in advance.
Re: Problem with ToolItem image [message #481732 is a reply to message #481696] Mon, 24 August 2009 07:02 Go to previous messageGo to next message
Stefan   is currently offline Stefan Friend
Messages: 316
Registered: July 2009
Senior Member
Hi,

using absolute paths isn't a good idea. Instead, put the images into
your bundle and load them using
getClass().getClassLoader().getResourceAsStream("/resources/image.png ");

Afterwards you can create an Image instance from your stream using
Graphics#getImage()

Regards,
Stefan.


B. Todorov schrieb:
> I create new tool item and set it Image from the hard drive. When I run
> the application with Eclipse Web Browser everything is perfect(All tool
> items have images). But when I run it in external browser(Firefox, IE)
> the tool items are there, but have no images. I have also added all
> images to the "Binnary build"
>
> ToolItem toolItem = new ToolItem(toolBar, SWT.PUSH);
> toolItem.setImage(ImageDescriptor.createFromURL("file:/E:/icons/image.png ").createImage());
>
>
> Can anybody help me solve the problem?
>
> Thanks in advance.
>
Re: Problem with ToolItem image [message #481926 is a reply to message #481732] Mon, 24 August 2009 18:03 Go to previous messageGo to next message
B. Todorov is currently offline B. TodorovFriend
Messages: 8
Registered: July 2009
Junior Member
Thanks
this solved my problem.
Regards
Re: Problem with ToolItem image [message #482817 is a reply to message #481732] Fri, 28 August 2009 08:13 Go to previous message
bjoern is currently offline bjoernFriend
Messages: 19
Registered: July 2009
Junior Member
Hi everybody,
just for the record I want to give an alternative solution. Having the
plugin-id and imagepath as strings you can get an ImageDescriptor as
follows:

Bundle bundle = Platform.getBundle(pluginId);
IPath path = new Path(imagePath);
URL imageUrl = FileLocator.find(bundle, path, null);
ImageDescriptor descriptor = ImageDescriptor.createFromURL(imageUrl);

The good thing on this solution is that it also works in RCP because it
does not make use of Graphics.

Maybe this is interesting to someone out there :)

Regards,
Björn

Stefan Roeck schrieb:
> Hi,
>
> using absolute paths isn't a good idea. Instead, put the images into
> your bundle and load them using
> getClass().getClassLoader().getResourceAsStream("/resources/image.png ");
>
> Afterwards you can create an Image instance from your stream using
> Graphics#getImage()
>
> Regards,
> Stefan.
>
>
> B. Todorov schrieb:
>> I create new tool item and set it Image from the hard drive. When I
>> run the application with Eclipse Web Browser everything is perfect(All
>> tool items have images). But when I run it in external
>> browser(Firefox, IE) the tool items are there, but have no images. I
>> have also added all images to the "Binnary build"
>>
>> ToolItem toolItem = new ToolItem(toolBar, SWT.PUSH);
>> toolItem.setImage(ImageDescriptor.createFromURL("file:/E:/icons/image.png ").createImage());
>>
>>
>> Can anybody help me solve the problem?
>>
>> Thanks in advance.
>>
Previous Topic:config.ini?
Next Topic:Text type listener problem
Goto Forum:
  


Current Time: Thu Apr 25 05:48:04 GMT 2024

Powered by FUDForum. Page generated in 0.02855 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top