JavaAwtToolkit demonstrates a few JavaPatterns. The java.awt.Toolkit is the glue that joins the platform-independent classes in the java.awt package with their counterparts in java.awt.peer. Some methods defined by Toolkit query the native operating system directly. java.awt.Toolkit is an AbstractFactory. Created through the SingletonPattern using the ParameterClasses JavaIdiom. public abstract class Toolkit { // '''Our singleton instance'''. private static Toolkit toolkit; public static synchronized Toolkit getDefaultToolkit() { if (toolkit == null) { try { java.lang.Compiler.disable(); java.security.Access''''''Controller.doPrivileged( new java.security.Privileged''''''Action() { public Object run() { String nm = null; try { // '''The ParameterClasses implementation'''. nm = System.getProperty("awt.toolkit", "sun.awt.motif.MToolkit"); toolkit = (Toolkit)Class.forName(nm).newInstance(); } catch (Class''''''Not''''''Found''''''Exception e) { throw new AWTError("Toolkit not found: " + nm); } catch (Instantiation''''''Exception e) { throw new AWTError("Could not instantiate Toolkit: " + nm); } catch (Illegal''''''Access''''''Exception e) { throw new AWTError("Could not access Toolkit: " + nm); } return null; } }); loadAssistiveTechnologies(); } finally { // Make sure to always re-enable the JIT. java.lang.Compiler.enable(); } } return toolkit; } Diagram of AbstractFactory: http://www.geekfarm.org/emeade/wikimages/abstractfactory.gif Diagram of Toolkit as AbstractFactory: http://www.geekfarm.org/emeade/wikimages/abstractfactory_toolkit.gif ---- See also TheStoryOfAwt ---- CategoryJavaPlatform