Question

I have developed an eclipse Plugin using Java SWT. My plugin has few Wizard Pages. Now, I need to add an image/logo on the header part of the Wizard Pages. Can anyone give suggestions on how to do the same using SWT please.

Was it helpful?

Solution

Images in a plugin are usually placed in an images or icons folder - don't forget to add this folder to the build.properties so that it will be included in the built plugin.

You load images from the folder using:

final URL fullPathString = FileLocator.find(bundle, new Path(path), null);

ImageDescriptor imageDesc = ImageDescriptor.createFromURL(fullPathString);

Image image = imageDesc.createImage();

bundle is your plugin Bundle, you can get this from your Activator (if you have one) or using:

Bundle bundle = Platform.getBundle("plugin id");

or

Bundle bundle = FrameworkUtil.getBundle(getClass());

path is the image path relative to the plugin - so something like images/xxx.gif

If you create an Image you must dispose of it when done (ImageDescriptor does not need to be disposed).

You can use org.eclipse.jface.resource.ImageRegistry to manage the images and image descriptors.

Update:

Once you have an ImageDescriptor you set it as the title image on a wizard page by calling WizardPage.setImageDescriptor(descriptor).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top