javafx-ui-common/src/com/sun/javafx/application/PlatformImpl.java
Print this page
@@ -27,10 +27,12 @@
import com.sun.javafx.PlatformUtil;
import com.sun.javafx.css.StyleManager;
import com.sun.javafx.runtime.SystemProperties;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.security.AccessControlContext;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.CountDownLatch;
@@ -74,10 +76,11 @@
private static Boolean hasTwoLevelFocus;
private static Boolean hasVirtualKeyboard;
private static Boolean hasTouch;
private static Boolean hasMultiTouch;
private static Boolean hasPointer;
+ private static boolean isThreadMerged = false;
/**
* Set a flag indicating whether this application should show up in the
* task bar. The default value is true.
*
@@ -142,10 +145,14 @@
}
s = System.getProperty("com.sun.javafx.pointer");
if (s != null) {
hasPointer = Boolean.valueOf(s);
}
+ s = System.getProperty("javafx.embed.singleThread");
+ if (s != null) {
+ isThreadMerged = Boolean.valueOf(s);
+ }
return null;
}
});
if (!taskbarApplication) {
@@ -171,10 +178,27 @@
@Override public void run() {
startupLatch.countDown();
r.run();
}
});
+
+ //Initialize the thread merging mechanism
+ if (isThreadMerged) {
+ //Use reflection in case we are running compact profile
+ try {
+ Class swingFXUtilsClass = Class.forName("javafx.embed.swing.SwingFXUtils");
+ Method installFwEventQueue = swingFXUtilsClass.getMethod("installFwEventQueue");
+
+ waitForStart();
+ installFwEventQueue.invoke(null);
+
+ } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException e) {
+ throw new RuntimeException("Property javafx.embed.singleThread is not supported");
+ } catch (InvocationTargetException e) {
+ throw new RuntimeException(e);
+ }
+ }
}
private static void waitForStart() {
// If the startup runnable has not yet been called, then wait it.
// Note that we check the count before calling await() to avoid