diff --git a/modules/graphics/src/main/java/javafx/application/Platform.java b/modules/graphics/src/main/java/javafx/application/Platform.java --- a/modules/graphics/src/main/java/javafx/application/Platform.java +++ b/modules/graphics/src/main/java/javafx/application/Platform.java @@ -25,6 +25,7 @@ package javafx.application; +import com.sun.javafx.tk.Toolkit; import javafx.beans.property.ReadOnlyBooleanProperty; import javafx.beans.property.ReadOnlyBooleanWrapper; import com.sun.javafx.application.PlatformImpl; @@ -168,6 +169,90 @@ return PlatformImpl.isSupported(feature); } + /** + * Indicates whether or not a nested event loop can be started + * from the current thread in the current state. Note that a nested + * event loop is not allowed outside of an event handler. + * + * @return flag indicating whether a nested event loop can be started. + * + * @since 9 + */ + public boolean canStartNestedEventLoop() { + return Toolkit.getToolkit().canStartNestedEventLoop(); + } + + /** + * Enter a nested event loop and block until the corresponding + * exitNestedEventLoop call is made. + * The key passed into this method is used to + * uniquely identify the matched enter/exit pair. This method creates a + * new nested event loop and blocks until the corresponding + * exitNestedEventLoop method is called with the same key. + * The return value of this method will be the {@code rval} + * object supplied to the exitNestedEventLoop method call that unblocks it. + * + * @param key the Object that identifies the nested event loop, which + * must not be null + * + * @throws IllegalArgumentException if the specified key is associated + * with a nested event loop that has not yet returned + * + * @throws NullPointerException if the key is null + * + * @throws IllegalStateException if this method is called on a thread + * other than the FX Application thread + * + * @return the value passed into the corresponding call to exitEventLoop + * + * @since 9 + */ + public Object enterNestedEventLoop(Object key) { + return Toolkit.getToolkit().enterNestedEventLoop(key); + } + + /** + * Exit a nested event loop and unblock the caller of the + * corresponding enterNestedEventLoop. + * The key passed into this method is used to + * uniquely identify the matched enter/exit pair. This method causes the + * nested event loop that was previously created with the key to exit and + * return control to the caller. If the specified nested event loop is not + * the inner-most loop then it will not return until all other inner loops + * also exit. + * + * @param key the Object that identifies the nested event loop, which + * must not be null + * + * @param rval an Object that is returned to the caller of the + * corresponding enterNestedEventLoop. This may be null. + * + * @throws IllegalArgumentException if the specified key is not associated + * with an active nested event loop + * + * @throws NullPointerException if the key is null + * + * @throws IllegalStateException if this method is called on a thread + * other than the FX Application thread + * + * @since 9 + */ + public void exitNestedEventLoop(Object key, Object rval) { + Toolkit.getToolkit().exitNestedEventLoop(key, rval); + } + + /** + * Checks whether a nested event loop is running, returning true to indicate + * that one is, and false if there are no nested event loops currently + * running. + * + * @return True if there is a nested event loop running, and false otherwise. + * @since 9 + */ + public boolean isNestedLoopRunning() { + return Toolkit.getToolkit().isNestedLoopRunning(); + } + private static ReadOnlyBooleanWrapper accessibilityActiveProperty; public static boolean isAccessibilityActive() {