not just this, other codes have the same problem. just can't use ImageView.
Environment : macOS, IntelliJ
Caused by: java.lang.IllegalArgumentException: Invalid URL: Invalid URL or resource not found
public class ShowHboxVbox extends Application {
static String s = "/Users/fangyuan/Desktop/PIC.png";
@Override
public void start(Stage primaryStage) {
BorderPane borderPane = new BorderPane();
borderPane.setTop(getHbox());
Scene scene = new Scene(borderPane);
primaryStage.setTitle("title");
primaryStage.setScene(scene);
primaryStage.show();
}
private HBox getHbox() {
HBox hBox = new HBox(15);
hBox.setPadding(new Insets(15,15,15,15));
hBox.setStyle("-fx-background-color: gold");
hBox.getChildren().add(new Button("computer science"));
hBox.getChildren().add(new Button("chemist"));
ImageView imageView = new ImageView(new Image(s));
hBox.getChildren().add(imageView);
return hBox;
}
}