List of usage examples for java.awt MediaTracker ERRORED
int ERRORED
To view the source code for java.awt MediaTracker ERRORED.
Click Source Link
From source file:org.xulux.swing.util.SwingUtils.java
/** * * @param resource the resource of the image * @param object the object to get the classloader from * @return the imageIcon found or null if not found *//*from ww w . j ava2 s . c o m*/ public static ImageIcon getIcon(String resource, Object object) { if (object == null) { return null; } ImageCache cache = null; if (object instanceof Widget) { Widget w = (Widget) object; if (w.getPart() != null) { cache = w.getPart().getImageCache(); } } ImageIcon icon = null; if (cache != null) { icon = cache.getImageIcon(resource); } if (icon == null) { URL imageURL = object.getClass().getClassLoader().getResource(resource); if (imageLoader != null) { icon = imageLoader.getIcon(imageURL); } else { if (imageURL != null) { icon = new ImageIcon(imageURL); if (icon.getImageLoadStatus() == MediaTracker.ERRORED) { icon = null; if (log.isWarnEnabled()) { log.warn("Image type " + resource + " not supported by swing " + "we advice you to add jimi to your classpath or convert your " + "image to an image type supported by swing"); } } } else { if (log.isWarnEnabled()) { log.warn("Image " + resource + " cannot be found"); } } } if (icon != null && cache != null) { cache.addImage(resource, icon); } } return icon; }