krs*_*rsi 8 javafx splash-screen preloader
我创建了一个Preloader(基于以下教程),它应该为主应用程序显示一个启动画面.
9.3.4使用预加载器显示应用程序初始化进度 http://docs.oracle.com/javafx/2/deployment/preloaders.htm
public class SplashScreenLoader extends Preloader {
private Stage splashScreen;
@Override
public void start(Stage stage) throws Exception {
splashScreen = stage;
splashScreen.setScene(createScene());
splashScreen.show();
}
public Scene createScene() {
StackPane root = new StackPane();
Scene scene = new Scene(root, 300, 200);
return scene;
}
@Override
public void handleApplicationNotification(PreloaderNotification notification) {
if (notification instanceof StateChangeNotification) {
splashScreen.hide();
}
}
}
Run Code Online (Sandbox Code Playgroud)
每次我在IDE(IntelliJ IDEA)中运行主应用程序时,我都想运行预加载器.
我还遵循IntelliJ中预加载器的打包规则:https: //www.jetbrains.com/idea/help/applications-with-a-preloader-project-organization-and-packaging.html
当我运行主应用程序时,预加载器没有启动,所以我想我错过了一些东西.我是Preloaders的新手,我不明白将主应用程序与独立应用程序中的预加载器连接的机制是什么.
你可以LauncherImpl像这样运行...
public class Main {
public static void main(String[] args) {
LauncherImpl.launchApplication(MyApplication.class, SplashScreenLoader.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
课程MyApplication就像这样...
public class MyApplication extends Application {
@Override
public void start(Stage primaryStage) {
....
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12007 次 |
| 最近记录: |