mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

jvergara
29.47.2008 a08dfbf6ce981e33ebe8ea1b2dbb2349818077ba
Extend the Utilities.createImageIcon method so that a specific ClassLoader can be used to retrieve the icons.
1 files modified
19 ■■■■ changed files
opends/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java 19 ●●●● patch | view | raw | blame | history
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.