Skip to main content



      Home
Home » Newcomers » Newcomers » How to use Images in an Eclipse plugin?
How to use Images in an Eclipse plugin? [message #67276] Fri, 20 May 2005 23:29 Go to next message
Eclipse UserFriend
Originally posted by: chibacity.gmail.com

Hi,

I've used some example code from the following article on www.eclipse.org

Using Images in the Eclipse UI (Revised for 2.0)

The method in question is:

private Image getIconImage(String name)
{
String iconPath = "icons/";
ImageDescriptor descriptor = null;

try {
URL installURL =
SubethaclipsePlugin.getDefault().getDescriptor().getInstallU RL();
URL url = new URL(installURL, iconPath + name);
descriptor = ImageDescriptor.createFromURL(url);
} catch (MalformedURLException e) {
System.err.println("MalformedURLException: " + e.getMessage());
return null;
}

return descriptor.createImage();
}

While this seems to work, the following are deprecated:

The method getDescriptor() from the type Plugin is deprecated
The method getInstallURL() from the type IPluginDescriptor is deprecated

I'm hoping someone can give me a hint as to what is the suggested way of
creating an Image object given a "gif" file located within the project. I'm
by no means an expert in the Eclipse framework, hence my turning to the
article in the first place for some example code.

Thanks in advance!

Regards,
Ben
Re: How to use Images in an Eclipse plugin? [message #67288 is a reply to message #67276] Fri, 20 May 2005 23:57 Go to previous message
Eclipse UserFriend
Originally posted by: chibacity.gmail.com

I found another post with a solution to this. Here is the example:

MyPlugin plugin extends AbstractUIPlugin
String relativeURL = "icon/myimage.png"

Image image = plugin.getImageRegistry().get( relativeURL );
if ( image == null ) {
URL imageURL = plugin .getBundle().getEntry( relativeURL );
ImageDescriptor descriptor = ImageDescriptor.createFromURL(imageURL);
Image image = descriptor.createImage();
plugin.getImageRegistry().put( relativeURL , image );
}


"Ben" wrote in message news:d6ma0o$926$1@news.eclipse.org...
> Hi,
>
> I've used some example code from the following article on www.eclipse.org
>
> Using Images in the Eclipse UI (Revised for 2.0)
>
> The method in question is:
>
> private Image getIconImage(String name)
> {
> String iconPath = "icons/";
> ImageDescriptor descriptor = null;
>
> try {
> URL installURL =
> SubethaclipsePlugin.getDefault().getDescriptor().getInstallU RL();
> URL url = new URL(installURL, iconPath + name);
> descriptor = ImageDescriptor.createFromURL(url);
> } catch (MalformedURLException e) {
> System.err.println("MalformedURLException: " + e.getMessage());
> return null;
> }
>
> return descriptor.createImage();
> }
>
> While this seems to work, the following are deprecated:
>
> The method getDescriptor() from the type Plugin is deprecated
> The method getInstallURL() from the type IPluginDescriptor is deprecated
>
> I'm hoping someone can give me a hint as to what is the suggested way of
> creating an Image object given a "gif" file located within the project.
> I'm by no means an expert in the Eclipse framework, hence my turning to
> the article in the first place for some example code.
>
> Thanks in advance!
>
> Regards,
> Ben
>
>
>
Previous Topic:Jsp not running on Eclipse3.0
Next Topic:How to install SDK 3.0.2 in Windows(2K)
Goto Forum:
  


Current Time: Tue Jul 22 14:48:42 EDT 2025

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

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

Back to the top