JavaFX Preloader and Netbeans

我的梦境 提交于 2021-02-19 05:37:33

问题


I am using the standard JavaFX preloader templete. But I am not sure how to link it to my JavaFX program.

public class FXPreloader extends Preloader {

    ProgressBar bar;
    Stage stage;
   .......
} 

And here is my Main

public class CIDCV extends Application {

 @Override
    public void start(Stage primaryStage) throws Exception {
        Parent root = FXMLLoader.load(getClass().getResource("Main.fxml"));
        Controller.stage=primaryStage;
        Scene scene = new Scene(root);
        Controller.stage.setScene(scene);
        Controller.stage.setResizable(false);
        Controller.stage.show();
    }
    public static void main(String[] args) {
      launch(args);
    }

}

All what I am looking for is a splash screen to indicate the program is starting.


回答1:


  1. Select the Application project
  2. Right-click for pop-up menu
  3. Select Properties in pop-up menu.
  4. Select Run in the Categories on the left side of dialog.
  5. Click the circled Browse button to select the project of your preloader.

Note for a small project locally the preloader might run so fast you can't even see it. I put in a Thread.sleep(1000) in handleProgressNotification() just to make sure I could see it.

See the section titled 9.2.1 Packaging a Preloader Application in NetBeans IDE in https://docs.oracle.com/javafx/2/deployment/preloaders.htm



来源:https://stackoverflow.com/questions/33683449/javafx-preloader-and-netbeans

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!