roskenet / springboot-javafx-support

SpringBoot / JavaFX8 Integration
MIT License
422 stars 139 forks source link

Add CSS file to Scene before launch #69

Open MBecM opened 6 years ago

MBecM commented 6 years ago

I want to add global.css file directly into Scene, but scene is not available before launch. My first attempt was to override beforeInitialView() method but scene is still not initialized.

public void beforeInitialView(Stage stage, ConfigurableApplicationContext ctx) {
    super.beforeInitialView(stage, ctx);
    stage.getScene().getStylesheets().addAll(getClass().getResource("global.css").toExternalForm());
}

public static void main(String[] args) {
    launch(Main.class, MainView.class, args);
}

I can set global.css in main.fxml, but this force me to set global.css in every possible root view in scene.

roskenet commented 6 years ago

Not sure yet, if I get you right... Need to check it.