JavaFX:未修饰的窗口 [英] JavaFX: Undecorated Window

查看:118
本文介绍了JavaFX:未修饰的窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作Windows PC Toast通知。现在我正在使用Swing和JavaFX的混合物,因为我没有找到一种方法来创建一个带有FX的未修饰窗口。我更愿意只使用JavaFX。

I am attempting to make a Windows PC Toast notification. Right now I am using a mixture of Swing and JavaFX because I did not find a way to make an undecorated window with FX. I would much prefer to only use JavaFX.

那么,我怎样才能制作一个未修饰的窗口?

So, how can I make an undecorated window?

编辑:我发现您可以使用 new Stage(StageStyle.UNDECORATED)直接创建一个舞台。

I have discovered that you can create a stage directly with new Stage(StageStyle.UNDECORATED).

现在我需要知道的是如何初始化工具包,这样我就可以在 MyApplication <中调用我的 start(阶段阶段)方法/ code>。 (扩展应用

Now all I need to know is how to initialize the toolkit so I can call my start(Stage stage) method in MyApplication. (which extends Application)

我通常调用 Application.launch(MyApplication.class, null),但这使我无法创建 Stage 并初始化 Toolkit

I usually call Application.launch(MyApplication.class, null), however that shields me from the creation of the Stage and initialization of the Toolkit.

那么我该如何做才能让我使用 start(new Stage(StageStyle.UNDECORATED))直接?

So how can I do these things to allow me to use start(new Stage(StageStyle.UNDECORATED)) directly?

推荐答案

我没有得到初步调用start()的方法 - 将方法设置为未修饰的方法,但下面的代码应该做你想要实现的。

I don't get your motivation for preliminary calling the start()-method setting a stage as undecorated, but the following piece of code should do what you want to achieve.

package decorationtest;

import javafx.application.Application;
import javafx.stage.StageStyle;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class DecorationTest extends Application {

    public static void main(String[] args) {
        Application.launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        primaryStage.initStyle(StageStyle.UNDECORATED);

        Group root = new Group();
        Scene scene = new Scene(root, 100, 100);

        primaryStage.setScene(scene);
        primaryStage.show();
    }
}

这篇关于JavaFX:未修饰的窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆