Пример #1
0
  /**
   * The value of <code>get(uidClassID)</code> must be the <code>String</code> name of a class that
   * implements the corresponding <code>ComponentUI</code> class. If the class hasn't been loaded
   * before, this method looks up the class with <code>uiClassLoader.loadClass()</code> if a non
   * <code>null</code> class loader is provided, <code>classForName()</code> otherwise.
   *
   * <p>If a mapping for <code>uiClassID</code> exists or if the specified class can't be found,
   * return <code>null</code>.
   *
   * <p>This method is used by <code>getUI</code>, it's usually not necessary to call it directly.
   *
   * @param uiClassID a string containing the class ID
   * @param uiClassLoader the object which will load the class
   * @return the value of <code>Class.forName(get(uidClassID))</code>
   * @see #getUI
   */
  public Class<? extends ComponentUI> getUIClass(String uiClassID, ClassLoader uiClassLoader) {
    try {
      String className = (String) get(uiClassID);
      if (className != null) {
        ReflectUtil.checkPackageAccess(className);

        Class cls = (Class) get(className);
        if (cls == null) {
          if (uiClassLoader == null) {
            cls = SwingUtilities.loadSystemClass(className);
          } else {
            cls = uiClassLoader.loadClass(className);
          }
          if (cls != null) {
            // Save lookup for future use, as forName is slow.
            put(className, cls);
          }
        }
        return cls;
      }
    } catch (ClassNotFoundException e) {
      return null;
    } catch (ClassCastException e) {
      return null;
    }
    return null;
  }