4 Replies Latest reply on May 21, 2013 5:39 PM by Kydo

    Getting return value from webengine.executescript when embedded in Swing


      Got a WebView embedded through a JFXPanel in a Swing app. I'm now trying to get some value back from the WebEngine.executeScript method in a synchronous way.

      All examples I can find on Swing embedding use Platform.runLater, which of course doesn't return the value straight away.

      Through some digging I found PlatformImpl.runAndWait(Runnable) and when I use that I do get a synchronous call and thus the return value of Webengine.executeScript immediately.

      Question now is if it's save for me to use PlatformImpl.runAndWait(Runnable) or if I should refrain from using it for some reason. I wasn't able to find anything on the topic, but so far in my tests if seems to work fine.

      Only thing I found were 2 implementations of sort of the same functionality: http://www.guigarage.com/2013/01/invokeandwait-for-javafx/ and https://code.google.com/p/jacp/source/browse/branches/working/JACP.JavaFX/src/main/java/org/jacp/javafx/rcp/worker/AFXComponentWorker.java (invokeOnFXThreadAndWait method)