|
|
|
Re: Problem with ToolItem image [message #482817 is a reply to message #481732] |
Fri, 28 August 2009 08:13 |
bjoern 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.
>>
|
|
|
Powered by
FUDForum. Page generated in 0.02855 seconds