From 8535a9ca92539bf12ec00cac7a4e47be604f0283 Mon Sep 17 00:00:00 2001
From: Jonas Smedegaard <dr@jones.dk>
Date: Sun, 27 Apr 2025 16:43:17 +0200
Subject: simplify path structure

---
 .../dk/biks/bachelorizer/view/Window.java          | 120 +++++++++++++++++++++
 1 file changed, 120 insertions(+)
 create mode 100644 src/dk.biks.bachelorizer/dk/biks/bachelorizer/view/Window.java

(limited to 'src/dk.biks.bachelorizer/dk/biks/bachelorizer/view/Window.java')

diff --git a/src/dk.biks.bachelorizer/dk/biks/bachelorizer/view/Window.java b/src/dk.biks.bachelorizer/dk/biks/bachelorizer/view/Window.java
new file mode 100644
index 0000000..c75e290
--- /dev/null
+++ b/src/dk.biks.bachelorizer/dk/biks/bachelorizer/view/Window.java
@@ -0,0 +1,120 @@
+// SPDX-FileCopyrightText: 2025 Jonas Smedegaard <dr@jones.dk>
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+package dk.biks.bachelorizer.view;
+
+import java.util.List;
+import javafx.application.Application;
+import javafx.scene.control.Button;
+import javafx.scene.control.Label;
+import javafx.scene.control.TextArea;
+import javafx.scene.control.TextField;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.VBox;
+import javafx.scene.Scene;
+import javafx.stage.Stage;
+
+import dk.biks.bachelorizer.Control;
+import dk.biks.bachelorizer.model.GUI;
+
+/// Bachelorizer - JavaFX Window view
+// Class is final to forbid subclassing,
+// because object is passed to controller during instatiation
+public final class Window extends Application { // the View
+
+	/// Default constructor
+	// (declared explicitly only to silence javadoc)
+	public Window() {
+	}
+
+	/// Label styling
+	public static String LABEL_STYLE =
+		"-fx-font-weight: bold; -fx-font-size: 20;";
+
+	/// Application model
+	private GUI model = new GUI();
+
+	/// Application controller
+	private Control control = new Control(model, this);
+
+	/// Name of student
+	private TextField nameEntry = new TextField();
+
+	/// Text entry for adding an activity
+	private TextField activityEntry = new TextField();
+
+	/// Text area for activity entries
+	private TextArea area = new TextArea();
+
+	/// Button to delete one activity
+	private Button delOne = new Button("Delete one");
+
+	/// Button to delete all activities
+	private Button delAll = new Button("Delete all");
+
+	/// Application instantiation
+	///
+	/// @param args  application parameters
+	public static void main(String[] args) {
+		launch(args);
+	}
+
+	@Override
+	public void start(Stage stage) {
+
+		// pass application parameters to controller
+		control.setParameters(getParameters().getRaw());
+
+		// add listeners
+//		NameEntry.setOnAction(e -> control.enterName(
+//			activityEntry.getText()));
+		activityEntry.setOnAction(e -> control.enterActivity(
+			activityEntry.getText()));
+		delOne.setOnAction(e -> control.delOne());
+		delAll.setOnAction(e -> control.delAll());
+
+		// add buttons
+		VBox root = new VBox(10,
+			ourHBox("Student", nameEntry),
+			ourHBox("Add activity", activityEntry),
+			new HBox(10, delOne, delAll),
+			area);
+
+		// compose stage
+		Scene scene = new Scene(root, 500, 500);
+		stage.setTitle("JavaFX Demo");
+		stage.setScene(scene);
+		stage.show();
+	}
+
+	/// action to apply student name
+	///
+	/// @param s  Text to apply
+	public void setStudentName(String s) {
+		nameEntry.setText(s);
+	}
+
+	/// action to apply text to area
+	///
+	/// @param s  Text to apply
+	public void setArea(String s) {
+		area.setText(s);
+	}
+
+	/// Button action to clear field
+	public void clearActivityEntry() {
+		activityEntry.setText("");
+	}
+
+	/// Styled HBox with label and TextField
+	///
+	/// @param s  Label string
+	/// @param f  Text field
+	/// @return   HBox containing styled label and text field
+	public HBox ourHBox(String s, TextField f) {
+		Label label = new Label(s+":");
+		label.setStyle(LABEL_STYLE);
+
+		return new HBox(10, label, f);
+	}
+}
-- 
cgit v1.2.3