[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.newcomer] Re: [solved] Where to put picture files?
|
- From: Ray Hurst <rhurst2@xxxxxxx>
- Date: Tue, 17 Mar 2009 07:55:55 -0700
- Newsgroups: eclipse.newcomer
- Organization: EclipseCorner
- User-agent: Thunderbird 2.0.0.19 (Windows/20081209)
I created a folder in the root of the project named icons.
I use this piece of code to wrap a resource that provides the location
for it.
I hope it helps.
/**
* Convenience class for storing references to image descriptors
*/
public class VDImages {
static final URL BASE_URL =
PicPlugin.getDefault().getBundle().getEntry("/"); //$NON-NLS-1$
static final String iconPath = "icons/"; //$NON-NLS-1$
static final String prefix = iconPath; //$NON-NLS-1$
public static final ImageDescriptor COMMENT_ACTION_IMAGE =
createImageDescriptor(prefix + "commentAction.gif"); //$NON-NLS-1$
public static final ImageDescriptor LABEL_ACTION_IMAGE =
createImageDescriptor(prefix + "labelAction.gif"); //$NON-NLS-1$;
/**
* Utility method to create an <code>ImageDescriptor</code>
* from a path to a file.
*/
private static ImageDescriptor createImageDescriptor(String path) {
try {
URL url = new URL(BASE_URL, path);
return ImageDescriptor.createFromURL(url);
} catch (MalformedURLException e) {
// do nothing
}
return ImageDescriptor.getMissingImageDescriptor();
}
}
Ray