From 4f181a3bde8b14c2c1a5aabce3b8893a93e82cd5 Mon Sep 17 00:00:00 2001 From: Roar Date: Thu, 16 Apr 2026 00:08:44 +0200 Subject: [PATCH 1/5] Updated pom.xml Added App as the main class. --- millions/pom.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/millions/pom.xml b/millions/pom.xml index bd65466..9981974 100644 --- a/millions/pom.xml +++ b/millions/pom.xml @@ -46,6 +46,9 @@ org.openjfx javafx-maven-plugin 0.0.8 + + no.ntnu.gruppe53.App + org.apache.maven.plugins From 9a940644df59ff642f92a7f62570f22ba9d926c7 Mon Sep 17 00:00:00 2001 From: Roar Date: Thu, 16 Apr 2026 00:11:39 +0200 Subject: [PATCH 2/5] Added ViewController Class for switching views. --- .../gruppe53/controller/ViewController.java | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 millions/src/main/java/no/ntnu/gruppe53/controller/ViewController.java diff --git a/millions/src/main/java/no/ntnu/gruppe53/controller/ViewController.java b/millions/src/main/java/no/ntnu/gruppe53/controller/ViewController.java new file mode 100644 index 0000000..c71dd4c --- /dev/null +++ b/millions/src/main/java/no/ntnu/gruppe53/controller/ViewController.java @@ -0,0 +1,60 @@ +package no.ntnu.gruppe53.controller; + +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.stage.Stage; + +import java.util.HashMap; +import java.util.Map; + +/** + * Manages application views and handles switching between them. + *

+ * Stores a mapping of view names to JavaFX {@link Parent} nodes and updates + * the current Scene by replacing its root node when switching views. + */ +public class ViewController { + /** Primary application window used to display the Scene. */ + private Stage stage; + /** Scene containing the currently active view. */ + private Scene scene; + /** Map of view identifiers to their corresponding UI roots. */ + private Map views = new HashMap<>(); + + /** + * Constructs a ViewController and initializes a new Scene. + * + * @param stage the primary application stage where the scene will be set + */ + public ViewController(Stage stage) { + this.stage = stage; + this.scene = new Scene(new javafx.scene.layout.StackPane(), 800, 600); + stage.setScene(scene); + } + + /** + * Registers a view in the controller. + * + * @param name unique identifier used to reference the view later + * @param view the JavaFX root node representing the view + */ + public void addView(String name, Parent view) { + views.put(name, view); + } + + /** + * Switches the currently displayed view by replacing the Scene root. + * + * @param name the identifier of the view to display + * @throws IllegalArgumentException if no view is registered under the given name + */ + public void switchView(String name) { + Parent view = views.get(name); + + if (view == null) { + throw new IllegalArgumentException("No views found matching: " + name); + } + + scene.setRoot(view); + } +} From 7169f15b41c3dde5c82ae6c727d035f5a295ed35 Mon Sep 17 00:00:00 2001 From: Roar Date: Thu, 16 Apr 2026 00:12:39 +0200 Subject: [PATCH 3/5] Updated ViewController Fixed javadoc typos. --- .../main/java/no/ntnu/gruppe53/controller/ViewController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/millions/src/main/java/no/ntnu/gruppe53/controller/ViewController.java b/millions/src/main/java/no/ntnu/gruppe53/controller/ViewController.java index c71dd4c..f33de22 100644 --- a/millions/src/main/java/no/ntnu/gruppe53/controller/ViewController.java +++ b/millions/src/main/java/no/ntnu/gruppe53/controller/ViewController.java @@ -12,6 +12,7 @@ *

* Stores a mapping of view names to JavaFX {@link Parent} nodes and updates * the current Scene by replacing its root node when switching views. + *

*/ public class ViewController { /** Primary application window used to display the Scene. */ From 15b7d8641cbf68f967a7938c08b6d5e501993292 Mon Sep 17 00:00:00 2001 From: Roar Date: Thu, 16 Apr 2026 00:14:14 +0200 Subject: [PATCH 4/5] Added StartView A currently dummy class to make the app launch with a default view. --- .../main/java/no/ntnu/gruppe53/views/StartView.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 millions/src/main/java/no/ntnu/gruppe53/views/StartView.java diff --git a/millions/src/main/java/no/ntnu/gruppe53/views/StartView.java b/millions/src/main/java/no/ntnu/gruppe53/views/StartView.java new file mode 100644 index 0000000..a1215c6 --- /dev/null +++ b/millions/src/main/java/no/ntnu/gruppe53/views/StartView.java @@ -0,0 +1,11 @@ +package no.ntnu.gruppe53.views; + +import javafx.scene.layout.VBox; +import no.ntnu.gruppe53.controller.ViewController; + +public class StartView extends VBox { + + public StartView(ViewController vm) { + + } +} \ No newline at end of file From 3b4cec7e92b81e5748cb7cf2c0fcc5623da54102 Mon Sep 17 00:00:00 2001 From: Roar Date: Thu, 16 Apr 2026 00:15:54 +0200 Subject: [PATCH 5/5] Updated App Added commands to make javafx work. --- .../src/main/java/no/ntnu/gruppe53/App.java | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/millions/src/main/java/no/ntnu/gruppe53/App.java b/millions/src/main/java/no/ntnu/gruppe53/App.java index 4205122..a446d34 100644 --- a/millions/src/main/java/no/ntnu/gruppe53/App.java +++ b/millions/src/main/java/no/ntnu/gruppe53/App.java @@ -1,10 +1,25 @@ package no.ntnu.gruppe53; -/** - * Hello world! - */ -public class App { +import javafx.application.Application; +import javafx.stage.Stage; +import no.ntnu.gruppe53.controller.ViewController; +import no.ntnu.gruppe53.views.StartView; + + +public class App extends Application { + @Override + public void start(Stage stage) { + ViewController vm = new ViewController(stage); + + vm.addView("start", new StartView(vm)); + + vm.switchView("start"); + + stage.setTitle("Millions - the Stock Game"); + stage.show(); + } + public static void main(String[] args) { - System.out.println("Hello World!"); + launch(); } }