maven - JavaFX Native Bundle 初始屏幕

标签 maven javafx executable splash-screen

我正在使用javafx-maven-plugin以及 Windows 7 上的 IntelliJ IDEA

我试图在我的 JavaFX 应用程序启动时显示启动屏幕,如下所示:

enter image description here

我尝试使用 SplashScreen-Image list 条目,并且有效,但前提是您单击 .jar - 我'我将应用程序部署为 Native Bundle,因此用户单击 .exe(或 .exe 的快捷方式)而不是实际的 .jar.

当您单击 .exe 时,不会显示启动屏幕。


This SSCCE I made将帮助帮助


如果我使用 javafx-maven-plugin 部署我的应用程序,(如果我没记错的话,它使用JavaFX Packager Tool,它使用 Inno Setup ),我怎样才能让启动屏幕在用户之后显示单击.exe

更多发现:

  • 查看安装目录,我发现一个名为 runtime\bin\splashscreen.dll 的 .dll。这是否意味着可以做到?

最佳答案

native 启动器不尊重该启动屏幕,仅在由 java 可执行文件调用时才尊重该启动器。由于 native 启动器在内部加载 JVM,因此这不起作用。

我还没有找到合适的方法来让它工作,即使使用一些预加载器也是如此。也许您会发现这很有帮助:https://gist.github.com/FibreFoX/294012b16fa10519674b (请忽略deltaspike相关的东西)

复制代码:

    @Override
    public void start(Stage primaryStage) throws Exception {
        // due to the nature of preloader being ignored within native-package, show it here
        SplashScreen splashScreen = new SplashScreen();
        splashScreen.show(new Stage(StageStyle.TRANSPARENT));

        // needed for callback
        final SomeJavaFXClassWithCDI launcherThread = this;

        // for splashscreen to be shown, its needed to delay everything else as parallel task/thread (it would block otherwise)
        Task cdiTask = new Task<Void>() {
            @Override
            protected Void call() throws Exception {
                // boot CDI after javaFX-splash (this will "halt" the application due to the work done by CDI-provider
                bootCDI(launcherThread);

                // push javaFX-work to javaFX-thread
                Platform.runLater(() -> {
                    primaryStage.setTitle("Some Title");


                    // TODO prepare your stage here !


                    // smooth fade-out of slashscreen
                    splashScreen.fadeOut((ActionEvent event) -> {
                        primaryStage.show();
                        splashScreen.hide();
                    });
                });
                return null;
            }
        };

        // run task
        new Thread(cdiTask).start();
}

简而言之:我正在自己创建启动画面。

免责声明:我是 javafx-maven-plugin 的维护者

关于maven - JavaFX Native Bundle 初始屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44061312/

相关文章:

java - 如何实现波斯日历

python - 系统路径中安装了多个Python

java - 不支持的 major.minor 版本 51.0 (org/apache/maven/cli/MavenCli) - MAC OS X

java - 使用 Geotools 将修改后的形状内容保存到 PostGIS 失败并出现 NullPointerException

java - 无法获取 org.hibernate.persister.entity.SingleTableEntityPersister 的构造函数 - BuldSession 错误

java - 初学者 : Extend a class in javaFx

JavaFX 获取特定 Pane 大小

python - py2exe 似乎缺少以下模块

windows - GAE 转到 Windows - "Cannot run program", "is not a valid Win32 application"

java - 在 IntelliJ IDEA 中使用 EclipseLink 构建 Java 代码失败