Browse Source

update AppController

main
fdai7736 11 months ago
parent
commit
200d92ff4a
  1. 2
      src/main/java/de/hsfulda/onses/App.java
  2. 15
      src/main/java/de/hsfulda/onses/controllers/AppController.java
  3. 7
      src/main/resources/de/hsfulda/onses/views/app.fxml

2
src/main/java/de/hsfulda/onses/App.java

@ -9,7 +9,7 @@ import javafx.stage.Stage;
public class App extends Application { public class App extends Application {
@Override @Override
public void start(Stage stage) throws Exception { 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.setTitle("Onses - Uno Game");
stage.setScene(new Scene(appController.render())); stage.setScene(new Scene(appController.render()));

15
src/main/java/de/hsfulda/onses/controllers/AppController.java

@ -1,29 +1,34 @@
package de.hsfulda.onses.controllers; package de.hsfulda.onses.controllers;
import de.hsfulda.onses.Main; import de.hsfulda.onses.Main;
import de.hsfulda.onses.models.Card;
import de.hsfulda.onses.models.Game; import de.hsfulda.onses.models.Game;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Parent; import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.stage.Stage;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Objects; import java.util.Objects;
public class AppController implements Controller { public class AppController implements Controller {
private final Game game; private final Game game;
private final Stage stage;
public AppController(Game game) {
public AppController(Game game, Stage stage) {
this.game = game; this.game = game;
this.stage = stage;
} }
@Override @Override
public Parent render() throws IOException { 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 button = (Button) parent.lookup("#startGameBtn");
button.setOnAction(e -> {
System.out.println("Pressed");
});
return parent; return parent;
} }
} }

7
src/main/resources/de/hsfulda/onses/views/app.fxml

@ -5,15 +5,14 @@
<?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<AnchorPane prefHeight="585.0" prefWidth="1125.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1">
<AnchorPane prefHeight="456.0" prefWidth="683.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1">
<children> <children>
<Label layoutX="473.0" layoutY="121.0" text="Uno Game" AnchorPane.leftAnchor="473.0" AnchorPane.topAnchor="121.0">
<Label layoutX="252.0" layoutY="96.0" text="Uno Game" AnchorPane.leftAnchor="252.0" AnchorPane.topAnchor="96.0">
<font> <font>
<Font size="34.0" /> <Font size="34.0" />
</font> </font>
</Label> </Label>
<Button fx:id="startGameBtn" layoutX="495.0" layoutY="275.0" mnemonicParsing="false" text="Start Game" AnchorPane.leftAnchor="495.0" AnchorPane.topAnchor="275.0">
<Button fx:id="startGameBtn" layoutX="274.0" layoutY="257.0" mnemonicParsing="false" text="Start Game" AnchorPane.leftAnchor="274.0" AnchorPane.topAnchor="257.0">
<font> <font>
<Font size="19.0" /> <Font size="19.0" />
</font> </font>

Loading…
Cancel
Save