public static Toolkit getDefaultToolkit() { if (toolkit != null) return toolkit; String toolkit_name = System.getProperty("awt.toolkit", default_toolkit_name); try { Class cls = Class.forName(toolkit_name); Object obj = cls.newInstance(); if (!(obj instanceof Toolkit)) throw new AWTError(toolkit_name + " is not a subclass of " + "java.awt.Toolkit"); toolkit = (Toolkit) obj; return toolkit; } catch (Exception e) { throw new AWTError("Cannot load AWT toolkit: " + e.getMessage()); } }
public static Toolkit getDefaultToolkit() { if (toolkit != null) return toolkit; String toolkit_name = System.getProperty("awt.toolkit", default_toolkit_name); try { final ClassLoader cl = Thread.currentThread().getContextClassLoader(); final Class cls = cl.loadClass(toolkit_name); Object obj = cls.newInstance(); if (!(obj instanceof Toolkit)) throw new AWTError(toolkit_name + " is not a subclass of " + "java.awt.Toolkit"); toolkit = (Toolkit) obj; return toolkit; } catch (Exception e) { throw new AWTError("Cannot load AWT toolkit: " + e.getMessage()); } }
  public static Toolkit getDefaultToolkit()  {    if (toolkit != null)      return toolkit;    String toolkit_name = System.getProperty("awt.toolkit",                                             default_toolkit_name);    try      {        Class cls = Class.forName(toolkit_name);        Object obj = cls.newInstance();        if (!(obj instanceof Toolkit))          throw new AWTError(toolkit_name + " is not a subclass of " +                             "java.awt.Toolkit");        toolkit = (Toolkit) obj;        return toolkit;      }    catch (Exception e)      {        throw new AWTError("Cannot load AWT toolkit: " + e.getMessage());      }  }