Jim
Jim

Reputation: 2161

Determine when JavaFX WebView has finished rendering

I want to use the JFX snapshot functionality as soon as the WebView has finished rendering. I can determine when the WebEngine has finished loading the page, but the worker will fire a State.SUCCEEDED before the WebView has finished rendering the page loaded by the worker.

I've tried webView.setVisible(true), webView.layout(), webView.requestLayout(), webView.autosize(), etc.

How can I determine when the pixels are displayed within the WebView? Alternatively, can I force the WebView to render and block until it is complete?

Upvotes: 2

Views: 4334

Answers (1)

Andy Till
Andy Till

Reputation: 3511

The JavaFX WebEngine which WebView uses allows calls from javascript to Java, so you could put a call to Java in the onload attribute of the page body. Check out the docs for WebEngine, especially the "Calling back to Java from JavaScript" section.

http://docs.oracle.com/javafx/2/api/javafx/scene/web/WebEngine.html

Upvotes: 2

Related Questions