Java Swing UIManager getClassLoaderForResources()

Here you can find the source of getClassLoaderForResources()

Description

Returns the class loader for loading the resource files.

License

Open Source License

Return

The class loader for loading the resource files.

Declaration

public static ClassLoader getClassLoaderForResources() 

Method Source Code

//package com.java2s;

import javax.swing.*;

public class Main {
    /**/* w w  w.j  a  v  a 2  s  .  co  m*/
     * Returns the class loader for loading the resource files. It is a fix by
     * Dag Joar and Christian Schlichtherle for application running with
     * -Xbootclasspath VM flag. In this case, the using
     * MyClass.class.getClassLoader() would return null, but the context class
     * loader will function properly that classes will be properly loaded
     * regardless of whether the lib is added to the system class path, the
     * extension class path and regardless of the class loader architecture set
     * up by some frameworks.
     * 
     * @return The class loader for loading the resource files.
     */
    public static ClassLoader getClassLoaderForResources() {
        ClassLoader cl = (ClassLoader) UIManager.get("ClassLoader");
        if (cl == null)
            cl = Thread.currentThread().getContextClassLoader();
        return cl;
    }
}

Related

  1. drawVistaBackground(Graphics g, Component b, String prefix)
  2. fixGtkPopupStyle()
  3. fixHtmlDisplay(JComponent component)
  4. getAnimationSpeed()
  5. getClassLoaderForResources()
  6. getDark()
  7. getDefaultActiveBackgroundColour()
  8. getDefaultAttributeSet()
  9. getDefaultFieldHeigth()