我正在使用javafx-maven-plugin以及 Windows 7 上的 IntelliJ IDEA。
我试图在我的 JavaFX 应用程序启动时显示启动屏幕,如下所示:
我尝试使用 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/