问题
I have a RCP application, in which I have added some images as icons. The below method is the method for adding icons on the buttons:
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();
}
}
}
where,
Button button
--> the button on which I need to add icons,Display d
--> current display,Bundle bundle
--> FrameworkUtil.getBundle(getClass());,String path
--> path of the icon.(for example - /icons/expandall.gif)
All the images are stored in icons
folder which is directly under the root project folder.
Note: I have no other references anywhere else in the whole project of the icons folder.
回答1:
Have you added icons in your build.properties ? You must open plugin.xml for instance, go to the build tab, and then check for the "icons" folder in the "Binary Build" section to indicates this folder will be bundled in your RCP application or plugin.
Hope that helps.
来源:https://stackoverflow.com/questions/35038375/images-are-not-appearing-in-rcp-application-after-exporting-as-a-product