我在Windows 7上使用javafx-maven-plugin和 IntelliJ IDEA 。
我试图在我的JavaFX应用程序启动时显示启动画面,如下所示:
我尝试使用SplashScreen-Image
清单条目和工作,但仅当您点击.jar
时 - 我将应用程序部署为< em> Native Bundle ,因此用户点击.exe
(或.exe
的快捷方式)而不是实际的.jar
。
当您点击.exe
时,会显示无启动画面。
This SSCCE I made将帮助您帮助我。
如果我使用javafx-maven-plugin部署我的应用,(如果我没弄错的话,请使用 JavaFX Packager Tool ,它使用 Inno Setup ),如何在用户点击.exe
后显示启动画面?
runtime\bin\splashscreen.dll
的.dll。这是否意味着它可以完成?答案 0 :(得分:3)
本机启动程序不尊重该spash-screen,只有在被java-executable调用时才会如此。由于本机启动程序在内部加载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的维护者