WebView中的JavaFX-HTML工具提示更改应用程序打开的其他窗口的z顺序

WebView中的JavaFX-HTML工具提示更改应用程序打开的其他窗口的z顺序,java,html,javafx,webview,tooltip,Java,Html,Javafx,Webview,Tooltip,当您将鼠标悬停在具有已在JavaFXWebView对象中呈现的已定义“title”属性的HTML元素上时,将显示显示在标题中定义的文本的工具提示 当应用程序打开的其他窗口位于包含webview的窗口顶部时,就会出现问题,在本例中,包含webview的窗口将显示在顶部,而其他窗口将显示在背景中,并完全或部分隐藏,具体取决于它们相对于包含webview的窗口的位置。以下代码示例演示了该问题: Java代码: package javaFXSandbox; import javafx.event.Ev

当您将鼠标悬停在具有已在JavaFXWebView对象中呈现的已定义“title”属性的HTML元素上时,将显示显示在标题中定义的文本的工具提示

当应用程序打开的其他窗口位于包含webview的窗口顶部时,就会出现问题,在本例中,包含webview的窗口将显示在顶部,而其他窗口将显示在背景中,并完全或部分隐藏,具体取决于它们相对于包含webview的窗口的位置。以下代码示例演示了该问题:

Java代码:

package javaFXSandbox;

import javafx.event.EventHandler;
import javafx.event.ActionEvent;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.Node;

import javafx.scene.web.WebView;
import javafx.scene.web.WebEngine;

import javafx.scene.layout.VBox;

import javafx.scene.control.Button;
import javafx.scene.control.Label;

import javafx.collections.ObservableList;

public class ToolTipBug extends Application {

    @Override
    public void start(Stage stage) {
        try {

            stage.setTitle("Web View");

            String htmlUrlStr = getClass().getResource("/resources/toolTipBug.html").toExternalForm();

            WebView webView = new WebView();
            webView.setPrefHeight(400);
            System.out.println("Preferred Height: " + webView.getPrefHeight());
            WebEngine webEngine = webView.getEngine();

            webEngine.load(htmlUrlStr);

            VBox root = new VBox(2);
            ObservableList<Node> vBoxChildren = root.getChildren();

            vBoxChildren.add(webView);

            Button button = new Button("Open a Popup");
            button.setOnAction(new EventHandler<ActionEvent>() {
                @Override
                public void handle(ActionEvent e) {
                    System.out.println("Opening a popup");
                    Stage stage = new Stage();
                    Label label = new Label("Hello World");
                    label.setPrefWidth(400);
                    label.setPrefHeight(300);
                    Scene scene = new Scene(label);
                    stage.setScene(scene);
                    stage.show();
                }
            });
            vBoxChildren.add(button);

            Scene scene = new Scene(root);
            stage.setScene(scene);
            stage.show();

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        launch(args);
    }
}
packagejavafxsandbox;
导入javafx.event.EventHandler;
导入javafx.event.ActionEvent;
导入javafx.application.application;
导入javafx.stage.stage;
导入javafx.scene.scene;
导入javafx.scene.Node;
导入javafx.scene.web.WebView;
导入javafx.scene.web.WebEngine;
导入javafx.scene.layout.VBox;
导入javafx.scene.control.Button;
导入javafx.scene.control.Label;
导入javafx.collections.ObservableList;
公共类ToolTipBug扩展了应用程序{
@凌驾
公众假期开始(阶段){
试一试{
stage.setTitle(“网络视图”);
字符串htmlUrlStr=getClass().getResource(“/resources/toolTipBug.html”).toExternalForm();
WebView WebView=新建WebView();
webView.setPrefHeight(400);
System.out.println(“首选高度:+webView.getPrefHeight());
WebEngine WebEngine=webView.getEngine();
webEngine.load(htmlUrlStr);
VBox根=新的VBox(2);
ObservableList vBoxChildren=root.getChildren();
添加(webView);
按钮按钮=新按钮(“打开弹出窗口”);
setOnAction(新的EventHandler(){
@凌驾
公共无效句柄(ActionEvent e){
System.out.println(“打开弹出窗口”);
阶段=新阶段();
标签=新标签(“你好世界”);
标签宽度(400);
标签高度(300);
场景=新场景(标签);
舞台场景;
stage.show();
}
});
vBoxChildren.add(按钮);
场景=新场景(根);
舞台场景;
stage.show();
}捕获(例外e){
e、 printStackTrace();
}
}
公共静态void main(字符串[]args){
发射(args);
}
}
以下是HTML:

    <html>
    <head>
        <link rel="stylesheet" href="css/toolTipSandbox.css"/>
    </head>
    <body>
    <div style="width:800px; height:600px; background-color:lightgrey">
        <div style="height:70px; width: 70px; background-color: salmon; padding:12px; border:1px solid black;" title="ToolTip">
            Hover Here
        </div>
    </div>
    </body>
    </html>

在这里盘旋

显然这不是问题的原因,但是您的演示代码缺少ActionEvent和EventHandler的导入语句。这肯定是一个bug。我在Java Bug数据库中找不到任何关于它的现有提及,因此您可能希望提交一个。