问题
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:
- Select the Application project
- Right-click for pop-up menu
- Select
Properties
in pop-up menu. - Select Run in the Categories on the left side of dialog.
- 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