0

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 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";   // this url is not okay 
         //   urlToGo =  " http://facebook.com";      // this url is okay 
         //  urlToGo = "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 enter image description here

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

2
  • I suggest that you change your client secret. Publishing secrets on the Internet is usually not a good idea. Commented Jun 16, 2016 at 17:29
  • Okay, I will remove the fancy URL from the projet all together. I have the same issue with just mail.google.com so I don't need a complicated url like that to show this problem. Thanks jewelsea! Commented Jun 17, 2016 at 6:27

2 Answers 2

1

I fixed the issue by adding -Dprism.order=j2d to VM options.

Sign up to request clarification or add additional context in comments.

Comments

0

Don's set layout x, ... when placing in an AnchorPane, use anchoring: AnchorPane.setLeftAnchor and similar

1 Comment

Done, thanks Milan but unfortunately this does not solve my issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.