Moe
Moe

Reputation: 1537

JavaFX Preloader and Netbeans

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.

Upvotes: 2

Views: 1002

Answers (1)

WillShackleford
WillShackleford

Reputation: 7018

  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.

enter image description here

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

Upvotes: 5

Related Questions