< prev index next >

src/java.desktop/share/classes/java/awt/GraphicsEnvironment.java

Print this page




  91      *
  92      * @return the graphics environment
  93      */
  94     private static GraphicsEnvironment createGE() {
  95         GraphicsEnvironment ge;
  96         String nm = AccessController.doPrivileged(new GetPropertyAction("java.awt.graphicsenv", null));
  97         try {
  98 //          long t0 = System.currentTimeMillis();
  99             Class<?> geCls;
 100             try {
 101                 // First we try if the bootstrap class loader finds the
 102                 // requested class. This way we can avoid to run in a privileged
 103                 // block.
 104                 geCls = Class.forName(nm);
 105             } catch (ClassNotFoundException ex) {
 106                 // If the bootstrap class loader fails, we try again with the
 107                 // application class loader.
 108                 ClassLoader cl = ClassLoader.getSystemClassLoader();
 109                 geCls = Class.forName(nm, true, cl);
 110             }
 111             ge = (GraphicsEnvironment)geCls.newInstance();


 112 //          long t1 = System.currentTimeMillis();
 113 //          System.out.println("GE creation took " + (t1-t0)+ "ms.");
 114             if (isHeadless()) {
 115                 ge = new HeadlessGraphicsEnvironment(ge);
 116             }
 117         } catch (ClassNotFoundException e) {
 118             throw new Error("Could not find class: "+nm);
 119         } catch (InstantiationException e) {
 120             throw new Error("Could not instantiate Graphics Environment: "
 121                             + nm);
 122         } catch (IllegalAccessException e) {
 123             throw new Error ("Could not access Graphics Environment: "
 124                              + nm);
 125         }
 126         return ge;
 127     }
 128 
 129     /**
 130      * Tests whether or not a display, keyboard, and mouse can be
 131      * supported in this environment.  If this method returns true,




  91      *
  92      * @return the graphics environment
  93      */
  94     private static GraphicsEnvironment createGE() {
  95         GraphicsEnvironment ge;
  96         String nm = AccessController.doPrivileged(new GetPropertyAction("java.awt.graphicsenv", null));
  97         try {
  98 //          long t0 = System.currentTimeMillis();
  99             Class<?> geCls;
 100             try {
 101                 // First we try if the bootstrap class loader finds the
 102                 // requested class. This way we can avoid to run in a privileged
 103                 // block.
 104                 geCls = Class.forName(nm);
 105             } catch (ClassNotFoundException ex) {
 106                 // If the bootstrap class loader fails, we try again with the
 107                 // application class loader.
 108                 ClassLoader cl = ClassLoader.getSystemClassLoader();
 109                 geCls = Class.forName(nm, true, cl);
 110             }
 111             @SuppressWarnings("deprecation")
 112             Object tmp = geCls.newInstance();
 113             ge = (GraphicsEnvironment)tmp;
 114 //          long t1 = System.currentTimeMillis();
 115 //          System.out.println("GE creation took " + (t1-t0)+ "ms.");
 116             if (isHeadless()) {
 117                 ge = new HeadlessGraphicsEnvironment(ge);
 118             }
 119         } catch (ClassNotFoundException e) {
 120             throw new Error("Could not find class: "+nm);
 121         } catch (InstantiationException e) {
 122             throw new Error("Could not instantiate Graphics Environment: "
 123                             + nm);
 124         } catch (IllegalAccessException e) {
 125             throw new Error ("Could not access Graphics Environment: "
 126                              + nm);
 127         }
 128         return ge;
 129     }
 130 
 131     /**
 132      * Tests whether or not a display, keyboard, and mouse can be
 133      * supported in this environment.  If this method returns true,


< prev index next >