导出为产品后,图像不会出现在RCP应用程序中

我有一个RCP应用程序,其中我添加了一些图像作为图标。 以下方法是在按钮上添加图标的方法:

public static void setIconForButton(Button button, Display d, Bundle bundle, String path) { InputStream is = null; try { is = FileLocator.openStream(bundle, new Path(path), false); Image image = new Image(d, is); button.setImage(image); } catch (IOException e1) { e1.printStackTrace(); } finally { try { if (is != null) { is.close(); } } catch (Exception e1) { e1.printStackTrace(); } } } 

哪里,

Button button – >我需要添加图标的按钮,
Display d – >当前显示,
Bundle bundle – > FrameworkUtil.getBundle(getClass());
String path – >图标的路径。(例如 – /icons/expandall.gif)

所有图像都存储在icons文件夹中,该文件夹直接位于根项目文件夹下。

注意:我在icons文件夹的整个项目中没有其他任何引用。

你在build.properties中添加了图标吗? 例如,您必须打开plugin.xml,转到构建选项卡,然后检查“二进制构建”部分中的“icons”文件夹,以指示此文件夹将捆绑在您的RCP应用程序或插件中。

希望有所帮助。