diff --git a/src/main/java/de/hsfulda/onses/App.java b/src/main/java/de/hsfulda/onses/App.java new file mode 100644 index 0000000..8712287 --- /dev/null +++ b/src/main/java/de/hsfulda/onses/App.java @@ -0,0 +1,18 @@ +package de.hsfulda.onses; + +import de.hsfulda.onses.controllers.AppController; +import de.hsfulda.onses.models.Game; +import javafx.application.Application; +import javafx.scene.Scene; +import javafx.stage.Stage; + +public class App extends Application { + @Override + public void start(Stage stage) throws Exception { + final AppController appController = new AppController(new Game()); + + stage.setTitle("Onses - Uno Game"); + stage.setScene(new Scene(appController.render())); + stage.show(); + } +} diff --git a/src/main/java/de/hsfulda/onses/Main.java b/src/main/java/de/hsfulda/onses/Main.java index fd78049..8bf1644 100644 --- a/src/main/java/de/hsfulda/onses/Main.java +++ b/src/main/java/de/hsfulda/onses/Main.java @@ -1,10 +1,9 @@ package de.hsfulda.onses; -import de.hsfulda.onses.controllers.MainController; import javafx.application.Application; public class Main { public static void main(String[] args) { - Application.launch(MainController.class); + Application.launch(App.class); } } \ No newline at end of file diff --git a/src/main/java/de/hsfulda/onses/controllers/AppController.java b/src/main/java/de/hsfulda/onses/controllers/AppController.java new file mode 100644 index 0000000..5f8a4cc --- /dev/null +++ b/src/main/java/de/hsfulda/onses/controllers/AppController.java @@ -0,0 +1,29 @@ +package de.hsfulda.onses.controllers; + +import de.hsfulda.onses.Main; +import de.hsfulda.onses.models.Game; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.control.Button; + +import java.io.IOException; +import java.util.Objects; + +public class AppController implements Controller { + + private final Game game; + + public AppController(Game game) { + this.game = game; + } + @Override + public Parent render() throws IOException { + final Parent parent = FXMLLoader.load(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/java/de/hsfulda/onses/controllers/Controller.java b/src/main/java/de/hsfulda/onses/controllers/Controller.java new file mode 100644 index 0000000..3a92766 --- /dev/null +++ b/src/main/java/de/hsfulda/onses/controllers/Controller.java @@ -0,0 +1,9 @@ +package de.hsfulda.onses.controllers; + +import javafx.scene.Parent; + +import java.io.IOException; + +public interface Controller { + Parent render() throws IOException; +} diff --git a/src/main/java/de/hsfulda/onses/controllers/MainController.java b/src/main/java/de/hsfulda/onses/controllers/MainController.java deleted file mode 100644 index ad84d77..0000000 --- a/src/main/java/de/hsfulda/onses/controllers/MainController.java +++ /dev/null @@ -1,22 +0,0 @@ -package de.hsfulda.onses.controllers; - -import de.hsfulda.onses.Main; -import javafx.application.Application; -import javafx.fxml.FXMLLoader; -import javafx.scene.Parent; -import javafx.scene.Scene; -import javafx.stage.Stage; - -import java.io.IOException; -import java.util.Objects; - -public class MainController extends Application { - @Override - public void start(Stage stage) throws IOException { - final Parent parent = FXMLLoader.load(Objects.requireNonNull(Main.class.getResource("views/main.fxml"))); - - stage.setTitle("Onses"); - stage.setScene(new Scene(parent)); - stage.show(); - } -} diff --git a/src/main/resources/de/hsfulda/onses/views/app.fxml b/src/main/resources/de/hsfulda/onses/views/app.fxml new file mode 100644 index 0000000..7facd52 --- /dev/null +++ b/src/main/resources/de/hsfulda/onses/views/app.fxml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + diff --git a/src/main/resources/de/hsfulda/onses/views/main.fxml b/src/main/resources/de/hsfulda/onses/views/main.fxml deleted file mode 100644 index 150a195..0000000 --- a/src/main/resources/de/hsfulda/onses/views/main.fxml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - -