-2

I am trying to update the background color but after entering the code below I am getting a null pointer exception.

enter image description here

enter image description here

I checked the path and added / but still nothing.

1 Answers1

0
try {
        Parent root = FXMLLoader.load(getClass().getResource("Main.fxml"));
        Scene scene = new Scene(root,600,400);
        scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
        //For more scenes:
        //String css = this.getClass().getResource("application.css").toExternalForm();
        //scene.getStylesheets().add(css);
        //
        primaryStage.setScene(scene);
        primaryStage.show();
    } catch(Exception e) {
        e.printStackTrace();
    }