最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - How to set a JavaFX window on top of other windows of all apps - Stack Overflow

programmeradmin0浏览0评论

How to set a JavaFX window on top of other windows, including other applications, games, and so on. I have a Linux operating system.

I need the window to be completely transparent and without a frame, and the elements in it were visible without problems. I also tried initStyle Undecorated with Modality.WINDOW_MODAL and in this case the window stays on top of other windows of my application only. Maybe someone knows how to do what I need to do.

public void initialize() {
        try {
            FXMLLoader loader = new FXMLLoader(SystemScopeMain.class.getResource("BenchWidget-view.fxml"));
            Parent root = loader.load();

            Stage transparentStage = new Stage();
            transparentStage.initStyle(StageStyle.TRANSPARENT);

            Scene scene = new Scene(root, 400, 300);
            scene.setFill(Color.TRANSPARENT);

            transparentStage.setScene(scene);
            transparentStage.setOpacity(0.4);
            transparentStage.initModality(Modality.WINDOW_MODAL);
            transparentStage.setAlwaysOnTop(true);

            transparentStage.setX(0);
            transparentStage.setY(0);

            transparentStage.show();

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

    }
发布评论

评论列表(0)

  1. 暂无评论