KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > gumby > widgets > Icon


1 package org.sapia.gumby.widgets;
2
3 import java.net.URL JavaDoc;
4
5 import javax.swing.ImageIcon JavaDoc;
6
7 import org.sapia.util.xml.confix.ConfigurationException;
8 import org.sapia.util.xml.confix.ObjectCreationCallback;
9
10 /**
11  * @author Yanick Duchesne
12  *
13  * <dl>
14  * <dt><b>Copyright: </b>
15  * <dd>Copyright &#169; 2002-2005 <a HREF="http://www.sapia-oss.org">Sapia Open
16  * Source Software </a>. All Rights Reserved.</dd>
17  * </dt>
18  * <dt><b>License: </b>
19  * <dd>Read the license.txt file of the jar or visit the <a
20  * HREF="http://www.sapia-oss.org/license.html">license page </a> at the Sapia
21  * OSS web site</dd>
22  * </dt>
23  * </dl>
24  */

25 public class Icon implements ObjectCreationCallback {
26
27   private String JavaDoc _src;
28
29   public void setSrc(String JavaDoc src) {
30     _src = src;
31   }
32
33   /**
34    * @see org.sapia.util.xml.confix.ObjectCreationCallback#onCreate()
35    */

36   public Object JavaDoc onCreate() throws ConfigurationException {
37     if(_src == null) {
38       throw new ConfigurationException("Icon source not specified");
39     }
40     URL JavaDoc url = getClass().getClassLoader().getResource(_src);
41     if(url == null) {
42       throw new ConfigurationException("Resource not found: " + _src);
43     }
44     return new ImageIcon JavaDoc(url);
45   }
46
47 }
48
Popular Tags