Author: tchemit Date: 2009-01-24 10:36:55 +0000 (Sat, 24 Jan 2009) New Revision: 1183 Modified: jaxx/trunk/jaxx-runtime-api/changelog.txt jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/Util.java Log: add a UIManager key "default.icon.path" to be able to change the path where to find icons Modified: jaxx/trunk/jaxx-runtime-api/changelog.txt =================================================================== --- jaxx/trunk/jaxx-runtime-api/changelog.txt 2009-01-23 21:54:09 UTC (rev 1182) +++ jaxx/trunk/jaxx-runtime-api/changelog.txt 2009-01-24 10:36:55 UTC (rev 1183) @@ -1,5 +1,6 @@ 1.1 chemit 200901?? * 20090123 [chemit] - add a simple createIcon method in Util classe (to create an icon with no path prefix) + - add a UIManager key "default.icon.path" to be able to change the path where to find icons * 20090122 [chemit] - refactor poms (sibling dependencies, pluginsManagment,...) 1.0 chemit 20090111 Modified: jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/Util.java =================================================================== --- jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/Util.java 2009-01-23 21:54:09 UTC (rev 1182) +++ jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/Util.java 2009-01-24 10:36:55 UTC (rev 1183) @@ -9,6 +9,7 @@ import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JList; +import javax.swing.UIManager; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; @@ -34,6 +35,9 @@ public class Util { + public static final String DEFAULT_ICON_PATH = "/icons/"; + public static final String DEFAULT_ICON_PATH_PROPERTY = "default.icon.path"; + /** to use log facility, just put in your code: log.info(\"...\"); */ static private final Log log = LogFactory.getLog(Util.class); @@ -448,15 +452,30 @@ * @return the icon at "/icons/"+path */ public static ImageIcon createImageIcon(String path) { - return createIcon("/icons/" + path); + String iconPath = getIconPath(); + return createIcon(iconPath + path); } public static ImageIcon createActionIcon(String name) { - return createIcon("/icons/action-" + name + ".png"); + String iconPath = getIconPath(); + return createIcon(iconPath + "action-" + name + ".png"); } public static ImageIcon createI18nIcon(String name) { - return createIcon("/icons/i18n/" + name + ".png"); + String iconPath = getIconPath(); + return createIcon(iconPath + "i18n/" + name + ".png"); } + private static String getIconPath() { + String iconPath = UIManager.getString(DEFAULT_ICON_PATH_PROPERTY); + if (iconPath == null) { + iconPath = DEFAULT_ICON_PATH; + } else { + if (!iconPath.endsWith("/")) { + iconPath += "/"; + } + } + return iconPath; + } + }