Hi, its my first time ting a project on JavaFx and everytime I try to run my program I get an error and I dont understand it

Viewed 42

Its my first time I try JavaFx and I am trying to make an UNO game but when I try to run my application I get an error saying is "Exception in Application start method java.lang.reflect.InvocationTargetException" I dont really understand what it means, and here is my code:


public class Main extends Application {

    Stage window;
    Scene startMenuScene,GameScene,playersMenu,playground;

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

    @Override
    public void start(Stage primaryStage) throws Exception {
        //Windows Needed to start
        window = primaryStage;

        Button start = new Button("start game");
        Button exit = new Button("Exit game");
        start.setStyle("-fx-background-color: #f57e05;");
        start.setOnAction(e -> switchScenes(playersMenu));
        exit.setOnAction((ActionEvent event) -> {Platform.exit();});

        start.setLayoutX(130);
        start.setLayoutY(350);
        start.setMinWidth(500);
        start.setMinHeight(100);

        exit.setLayoutX(130);
        exit.setLayoutY(500);
        exit.setMinWidth(500);
        exit.setMinHeight(100);

        start.setStyle("-fx-font-size:40");
        exit.setStyle("-fx-font-size:40");
        Group root = new Group();

        //Start Menu Color and size
        startMenuScene = new Scene(root,400,250 ,Color.SALMON);

        //Scene
        window.setScene(startMenuScene);
        window.setFullScreen(true);
        window.setTitle("UNO");
        window.show();

    }

    public void switchScenes(Scene scene){
        window.setScene(scene);
        window.setFullScreen(true);
    }
}

0 Answers
Related