From 200d92ff4af323bc986cb63973a63b29ad32accd Mon Sep 17 00:00:00 2001 From: fdai7736 Date: Tue, 6 Feb 2024 20:22:19 +0100 Subject: [PATCH] update AppController --- src/main/java/de/hsfulda/onses/App.java | 2 +- .../hsfulda/onses/controllers/AppController.java | 15 ++++++++++----- .../resources/de/hsfulda/onses/views/app.fxml | 7 +++---- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/main/java/de/hsfulda/onses/App.java b/src/main/java/de/hsfulda/onses/App.java index 8712287..b1e280a 100644 --- a/src/main/java/de/hsfulda/onses/App.java +++ b/src/main/java/de/hsfulda/onses/App.java @@ -9,7 +9,7 @@ import javafx.stage.Stage; public class App extends Application { @Override public void start(Stage stage) throws Exception { - final AppController appController = new AppController(new Game()); + final AppController appController = new AppController(new Game(), stage); stage.setTitle("Onses - Uno Game"); stage.setScene(new Scene(appController.render())); diff --git a/src/main/java/de/hsfulda/onses/controllers/AppController.java b/src/main/java/de/hsfulda/onses/controllers/AppController.java index 5f8a4cc..d1eb5b4 100644 --- a/src/main/java/de/hsfulda/onses/controllers/AppController.java +++ b/src/main/java/de/hsfulda/onses/controllers/AppController.java @@ -1,29 +1,34 @@ package de.hsfulda.onses.controllers; import de.hsfulda.onses.Main; +import de.hsfulda.onses.models.Card; import de.hsfulda.onses.models.Game; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; +import javafx.scene.Scene; import javafx.scene.control.Button; +import javafx.stage.Stage; import java.io.IOException; +import java.util.ArrayList; import java.util.Objects; public class AppController implements Controller { private final Game game; + private final Stage stage; - public AppController(Game game) { + public AppController(Game game, Stage stage) { this.game = game; + this.stage = stage; } @Override public Parent render() throws IOException { - final Parent parent = FXMLLoader.load(Main.class.getResource("views/app.fxml")); + GameController gameController = new GameController(game); + final Parent parent = FXMLLoader.load(Objects.requireNonNull(Main.class.getResource("views/app.fxml"))); Button button = (Button) parent.lookup("#startGameBtn"); - button.setOnAction(e -> { - System.out.println("Pressed"); - }); + return parent; } } diff --git a/src/main/resources/de/hsfulda/onses/views/app.fxml b/src/main/resources/de/hsfulda/onses/views/app.fxml index 7facd52..7205ca5 100644 --- a/src/main/resources/de/hsfulda/onses/views/app.fxml +++ b/src/main/resources/de/hsfulda/onses/views/app.fxml @@ -5,15 +5,14 @@ - - + -