Whenever I run it, it shows an error because it can't find the file.
This is with intelliJ, I've tried many solutions but they aren't working.
Someone replied before but I'm pretty sure I did their fix wrong because before it was showing a blank part where the image should be, but now it is giving me errors.
package GUI;
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;
import javafx.scene.layout.VBox;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import java.io.File;
import java.util.Objects;
public class GameGUI extends Application{
@Override
public void start(Stage primaryStage) {
//Sets the stage
//Stage Menu = new Stage();
//Cheske Pic
Image cheske = new Image(getClass().getResourceAsStream("src/main/resources/CheskePic.png"));
ImageView cheskePic = new ImageView(cheske);
cheskePic.setFitHeight(200);
cheskePic.setFitWidth(200);
//Choose Pieces Button
Button Pieces = new Button("Choose Your Pieces");
Pieces.setOnAction(e -> {
//Edit the 2-D Array
});
//Start Game Button
Button Start = new Button("Start");
Start.setOnAction(e -> {
//BoardGUI.show();
});
//Quit Game Button
Button Quit = new Button("Quit");
Quit.setOnAction(e -> {
primaryStage.close();
});
//Sets the layout with all the buttons / pic
VBox layout = new VBox(10);
layout.getChildren().addAll(cheskePic,Pieces,Start,Quit);
layout.setAlignment(Pos.CENTER);
//Sets the scene with the layout we have given it
Scene scene = new Scene(layout, 400, 400);
//Sets all stage settings then shows the Menu
primaryStage.setTitle("Hello!");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args){
launch();
}
}