Cannot load image for region

35 Views Asked by At

Why doesn't JavaFX load my image for region though there is no error?

HelloApplication.java

public class HelloApplication extends Application {
    @Override
    public void start(Stage stage) throws IOException {
        Region region = new Region();
        region.setId("region");
        Scene scene = new Scene(region,500,500);
        region.getStylesheets().addAll(getClass().getResource("css.css").toExternalForm());
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

css.css

#region {
    -fx-background-image: url('/com/example/demotmp/Asset1.png');
}

My structure file enter image description here

0

There are 0 best solutions below