From a08dfbf6ce981e33ebe8ea1b2dbb2349818077ba Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Sat, 29 Nov 2008 12:47:53 +0000
Subject: [PATCH] Extend the Utilities.createImageIcon method so that a specific ClassLoader can be used to retrieve the icons.
---
opends/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java | 19 +++++++++++++++++--
1 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java b/opends/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java
index b8cd3df..6c1f9e2 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java
@@ -895,10 +895,16 @@
/**
* Returns an ImageIcon or <CODE>null</CODE> if the path was invalid.
* @param path the path of the image.
+ * @param loader the class loader to use to load the image. If
+ * <CODE>null</CODE> this class class loader will be used.
* @return an ImageIcon or <CODE>null</CODE> if the path was invalid.
*/
- public static ImageIcon createImageIcon(String path) {
- java.net.URL imgURL = ControlPanel.class.getClassLoader().getResource(path);
+ public static ImageIcon createImageIcon(String path, ClassLoader loader) {
+ if (loader == null)
+ {
+ loader = ControlPanel.class.getClassLoader();
+ }
+ java.net.URL imgURL = loader.getResource(path);
if (imgURL != null) {
return new ImageIcon(imgURL);
} else {
@@ -908,6 +914,15 @@
}
/**
+ * Returns an ImageIcon or <CODE>null</CODE> if the path was invalid.
+ * @param path the path of the image.
+ * @return an ImageIcon or <CODE>null</CODE> if the path was invalid.
+ */
+ public static ImageIcon createImageIcon(String path) {
+ return createImageIcon(path, null);
+ }
+
+ /**
* Creates an image icon using an array of bytes that contain the image and
* specifying the maximum height of the image.
* @param bytes the byte array.
--
Gitblit v1.10.0