private Image createImage() {
Image image = null;
ImageDescriptor imageDescriptor = Activator.getImageDescriptor(imagePath);
if(imageDescriptor != null) {
image = imageDescriptor.createImage();
}
else {
System.out.print("Image path error!");
}
return image;
}
imagePath为String类型image的相对路径,格式为"icons/sample.png",不可以设为"./icons/sample.png"或"/icons/sample.png"。
其中class Activator定义如下:
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "com.license.ui"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
plugin = this;
}
@Override
public void start(BundleContext context) throws Exception {
super.start(cont