将映像导入Eclipse插件

问题描述 投票:1回答:1

我已经使用Java SWT开发了eclipse插件。我的插件只有几个向导页面。现在,我需要在向导页面的标题部分添加图像/徽标。任何人都可以提出有关如何使用SWT进行操作的建议。

swt eclipse-plugin
1个回答
5
投票

插件中的图像通常放置在imagesicons文件夹中-不要忘记将此文件夹添加到build.properties中,以便将其包含在内置插件中。

您使用以下方法从文件夹中加载图像:

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

ImageDescriptor imageDesc = ImageDescriptor.createFromURL(fullPathString);

Image image = imageDesc.createImage();

[bundle是您的插件Bundle,您可以从激活器(如果有)获得此插件,或者使用:]]

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

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

[path是相对于插件的图像路径-类似于images/xxx.gif

如果创建Image,则必须在完成后将其处置(无需处置ImageDescriptor)。

您可以使用org.eclipse.jface.resource.ImageRegistry管理图像和图像描述符。

更新:

一旦有了ImageDescriptor,就可以通过调用WizardPage.setImageDescriptor(descriptor)将其设置为向导页面上的标题图像。

© www.soinside.com 2019 - 2024. All rights reserved.