Skip to content

GraphicsEnvironmentClass

Eric Bodden edited this page Mar 15, 2015 · 1 revision
package java.awt;
GraphicsEnvironment.class
  public static synchronized GraphicsEnvironment getLocalGraphicsEnvironment() {
	if (localEnv == null) {
	    String nm = (String) java.security.AccessController.doPrivileged
		(new sun.security.action.GetPropertyAction
		 ("java.awt.graphicsenv", null));

	    try {
// 			long t0 = System.currentTimeMillis();
		localEnv =
		    (GraphicsEnvironment) Class.forName(nm).newInstance();
// 		long t1 = System.currentTimeMillis();
// 		System.out.println("GE creation took " + (t1-t0)+ "ms.");
                if (isHeadless()) {
                    localEnv = new HeadlessGraphicsEnvironment(localEnv);
                }
	    } catch (ClassNotFoundException e) {
                throw new Error("Could not find class: "+nm);
            } catch (InstantiationException e) {
                throw new Error("Could not instantiate Graphics Environment: "
				+ nm);
            } catch (IllegalAccessException e) {
                throw new Error ("Could not access Graphics Environment: "
				 + nm);
            }
        }

	return localEnv;
    }
Clone this wiki locally