简体   繁体   中英

How to get icons from the icons folder of eclipse plugin project

I have some Icons in the Icons Folder of my plugin Project, which i want to use them in setting images in columns of my TreeViewer.

I have tried in two ways to get the Image

1)

       Bundle bundle = FrameworkUtil.getBundle(INF2TreeLabelProvider.class);
    URL url = FileLocator.find(bundle, new Path(icons/abc.png), null);
    ImageDescriptor imageDcr = ImageDescriptor.createFromURL(url);
    Image image = imageDcr.createImage();

2)

 ImageDescriptor imgDesc = AbstractUIPlugin.imageDescriptorFromPlugin("plugin-name", icons/abc.png);
 Image image = imgDesc.createImage();

With code snippet 1) , i get a null URL object and with code snippet 2) , i get a null ImageDescriptor

Am I missing anything here?

Have you tried including icons/ directory in build.properties file? Something like:

bin.includes = plugin.xml,\
           META-INF/,\
           .,\
           icons/,\
           OSGI-INF/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM