Example #1
0
  static {
    JAWTJNILibLoader.loadAWTImpl();
    JAWTJNILibLoader.loadNativeWindow("awt");

    headlessMode = GraphicsEnvironment.isHeadless();

    boolean ok = false;
    Class jC = null;
    Method m = null;
    if (!headlessMode) {
      try {
        jC = Class.forName("com.jogamp.opengl.impl.awt.Java2D");
        m = jC.getMethod("isQueueFlusherThread", null);
        ok = true;
      } catch (Exception e) {
      }
    }
    j2dClazz = jC;
    isQueueFlusherThread = m;
    j2dExist = ok;

    AccessController.doPrivileged(
        new PrivilegedAction() {
          public Object run() {
            try {
              sunToolkitClass = Class.forName("sun.awt.SunToolkit");
              sunToolkitAWTLockMethod =
                  sunToolkitClass.getDeclaredMethod("awtLock", new Class[] {});
              sunToolkitAWTLockMethod.setAccessible(true);
              sunToolkitAWTUnlockMethod =
                  sunToolkitClass.getDeclaredMethod("awtUnlock", new Class[] {});
              sunToolkitAWTUnlockMethod.setAccessible(true);
            } catch (Exception e) {
              // Either not a Sun JDK or the interfaces have changed since 1.4.2 / 1.5
            }
            return null;
          }
        });
    boolean _hasSunToolkitAWTLock = false;
    if (null != sunToolkitAWTLockMethod && null != sunToolkitAWTUnlockMethod) {
      try {
        sunToolkitAWTLockMethod.invoke(null, null);
        sunToolkitAWTUnlockMethod.invoke(null, null);
        _hasSunToolkitAWTLock = true;
      } catch (Exception e) {
      }
    }
    hasSunToolkitAWTLock = _hasSunToolkitAWTLock;
    // useSunToolkitAWTLock = hasSunToolkitAWTLock;
    useSunToolkitAWTLock = false;
  }
Example #2
0
 public static final boolean isJava2DQueueFlusherThread() {
   boolean b = false;
   if (j2dExist) {
     try {
       b = ((Boolean) isQueueFlusherThread.invoke(null, null)).booleanValue();
     } catch (Exception e) {
     }
   }
   return b;
 }
Example #3
0
 private static void awtUnlock() {
   if (useSunToolkitAWTLock) {
     try {
       sunToolkitAWTUnlockMethod.invoke(null, null);
     } catch (Exception e) {
       throw new NativeWindowException("SunToolkit.awtUnlock failed", e);
     }
   } else {
     JAWT.getJAWT().Unlock();
   }
 }