The following code shows a weird behavior in JDK 9.0.1 (Windows):
Dialog Snippet
Dialog<Void> dialog = new Dialog<>();
WebView webView = new WebView();
dialog.getDialogPane().setContent(webView);
webView.getEngine().load("http://docs.oracle.com/javafx/");
dialog.show();
The WebView actually loads, but it does not render the web content to the GUI.
Proof Snippet
I had the following code (I edited it for simplicity sake)
private void loadSite(String url) throws IOException {
CookieManager cookieManager = new CookieManager();
CookieHandler.setDefault(cookieManager);
URI uri = URI.create(url);
Map<String, List<String>> headers = new HashMap<>();
CookieHandler.getDefault().put(uri, headers);
webEngine.getLoadWorker().stateProperty()
.addListener((observable, oldValue, newValue) -> {
System.out.println(newValue);
if (newValue == Worker.State.SUCCEEDED) {
System.out.println(cookieManager.getCookieStore().getCookies());
}
});
webEngine.load(url);
}
This snippet is used to print cookies from a fully loaded page. The worker reaches State.SUCCEEDED and the cookies get printed out, but the WebView doesn't render the web page.
Working Snippet
I tried the following snippet and it worked, the WebView actually renders the web page to the GUI:
Stage stage = new Stage();
final WebView webView = new WebView();
webView.getEngine().load("http://docs.oracle.com/javafx/");
stage.setScene(new Scene(webView));
stage.show();
The Dialog Snippet works with JDK 8 but not JDK 9.
Side by side comparison
Stage Snippet left, Dialog Snippet Right
Actual Question
Am I doing something wrong? why is this happening? I read some of the JDK 9 changes, but I didn't see anything relatable.
Thanks in advance for any colaboration.