0

For some reason, I can't seem to get my image to show, though the button will show.

    package sample;

   /* Removed Package Import Statements*/

    public class Main extends Application {
    @Override
    public void start(Stage primaryStage) throws Exception{
        GridPane gridPane = new GridPane();
        Image empty = new Image("File:empty.png");
        ImageView view = new ImageView(empty);
        Button button = new Button("Some Button");
        GridPane.setRowIndex(button, 0);
        GridPane.setColumnIndex(button, 1);
        gridPane.setRowIndex(view, 0);
        gridPane.setColumnIndex(view, 0);
        gridPane.getChildren().addAll(view, button);
        primaryStage.setTitle("Hello World");
        primaryStage.setScene(new Scene(gridPane, 561, 400));
        primaryStage.show();
    }


    public static void main(String[] args) {
        launch(args);
    }
}
kleopatra
  • 51,061
  • 28
  • 99
  • 211
uweo030
  • 33
  • 4
  • try to read this article: https://stackoverflow.com/questions/16099427/cannot-load-image-in-javafx – Mustafa Poya Nov 29 '20 at 06:00
  • 1
    Does this answer your question? [Cannot load image in JavaFX](https://stackoverflow.com/questions/16099427/cannot-load-image-in-javafx) – Mustafa Poya Nov 29 '20 at 06:00

0 Answers0