Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using WebView in JavaFX breaks the UI on Linux

3260940Jun 18 2016 — edited Jul 13 2016

Hi,

I would like to have a webview component and a button on the stage but when I load a http://mail.google.com in the WebView the other button drawn on the stage gets problems.

After having loaded the page successfully if I hover on the button with the mouse the button itself disappears leaving only its label visible.

The problem is only on Linux since when I tried the same project with Windows it was okay.

The funny story is that if I change the url I want to load with another one, say http://www.google.com the button is not affected by this weird problem.

My Linux 64 bit Mint 17.3 and the Java version is jdk1.8.0_91. Here is the code, a video (Youtube url https://youtu.be/13F8U6vQyoY) and some screenshots of the strange behaviour.

package javafxwebviewnofxml;

import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.layout.AnchorPane; import javafx.scene.web.WebEngine; import javafx.scene.web.WebView; import javafx.stage.Stage; /** * * @author Aldo Marx */ public class JavaFXWebviewNoFXML extends Application { public WebEngine webEngine; public String urlToGo; public AnchorPane anchorPane; private WebView webView; @Override public void start(Stage primaryStage) { Button btn = new Button(); btn.setText("Say 'Hello World'"); btn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { System.out.println("Hello World my friends!"); } }); anchorPane = new AnchorPane() ; anchorPane.setPrefSize(1160, 900); AnchorPane.setLeftAnchor(btn, 900.00); AnchorPane.setTopAnchor(btn, 400.00); webView = new WebView(); webView.setPrefSize(1160, 900); webEngine = webView.getEngine(); urlToGo = "[http://mail.google.com](http://mail.google.com/)"; // this url is not okay // urlToGo = " [http://facebook.com](http://facebook.com/)"; // this url is okay // urlToGo = "[http://www.google.com](http://www.google.com/)"; // this url is okay webEngine.load(urlToGo); anchorPane.getChildren().addAll(webView); anchorPane.getChildren().addAll(btn); Scene scene = new Scene(anchorPane, 1160, 900); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); } }

The button as appears on the stage when it's not hovered by the mouse can be seen here below

OdUSR.png

The button as appears on the stage when it is hovered by the mouse (and this is the problem ) can be seen here below

![later.png](https://objectstorage.us-phoenix-1.oraclecloud.com/p/BqK85Rn1zA5MP0vYiqbAdPgs7Z6OmMxw8SD3WCFVm5kY8uReidZ1KPIKkgJ1hCkG/n/axciphqpnohg/b/forums-legacy/o/uploads/jive_attachments/5/6/9/56968154egami.png)

I hope I can get some advise, Thanks a million

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 10 2016
Added on Jun 18 2016
2 comments
1,060 views