From f0995fbf27de630619849e1b0aac4fd5069aa9f3 Mon Sep 17 00:00:00 2001
From: romanschenk37 <84532681+romanschenk37@users.noreply.github.com>
Date: Tue, 29 Mar 2022 22:07:37 +0200
Subject: [PATCH] Aufgabe 4 MainWindow.fxml erstellt.
---
code/FXML-Calculator/build.gradle | 2 +-
.../ch/zhaw/prog2/fxmlcalculator/Main.java | 23 +++-
.../fxmlcalculator/MainWindowController.java | 39 ++++++-
.../zhaw/prog2/fxmlcalculator/MainWindow.fxml | 108 +++++++++++++++++-
4 files changed, 164 insertions(+), 8 deletions(-)
diff --git a/code/FXML-Calculator/build.gradle b/code/FXML-Calculator/build.gradle
index 9801fef..c474171 100644
--- a/code/FXML-Calculator/build.gradle
+++ b/code/FXML-Calculator/build.gradle
@@ -34,7 +34,7 @@ application {
// Configuration for JavaFX plugin
javafx {
version = '17'
- modules = [ 'javafx.controls' ]
+ modules = [ 'javafx.controls', 'javafx.fxml' ]
}
// Java plugin configuration
diff --git a/code/FXML-Calculator/src/main/java/ch/zhaw/prog2/fxmlcalculator/Main.java b/code/FXML-Calculator/src/main/java/ch/zhaw/prog2/fxmlcalculator/Main.java
index 19e0863..f227554 100644
--- a/code/FXML-Calculator/src/main/java/ch/zhaw/prog2/fxmlcalculator/Main.java
+++ b/code/FXML-Calculator/src/main/java/ch/zhaw/prog2/fxmlcalculator/Main.java
@@ -7,7 +7,7 @@ import javafx.scene.layout.Pane;
import javafx.stage.Stage;
/**
* Main-Application. Opens the first window (MainWindow) and the common ValueHandler
- * @author
+ * @author
* @version 1.0
*/
public class Main extends Application {
@@ -26,7 +26,28 @@ public class Main extends Application {
private void mainWindow(Stage primaryStage) {
//load main window
+ try {
+ FXMLLoader loader = new FXMLLoader(getClass().getResource("MainWindow.fxml"));
+
+ Pane rootNode = loader.load();
+
+ MainWindowController mainWindowController = loader.getController();
+
+
+ Scene scene = new Scene(rootNode);
+
+ primaryStage.setScene(scene);
+ primaryStage.show();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
}
+
+
+
+
+
+
}
diff --git a/code/FXML-Calculator/src/main/java/ch/zhaw/prog2/fxmlcalculator/MainWindowController.java b/code/FXML-Calculator/src/main/java/ch/zhaw/prog2/fxmlcalculator/MainWindowController.java
index dff952f..1ad19ac 100644
--- a/code/FXML-Calculator/src/main/java/ch/zhaw/prog2/fxmlcalculator/MainWindowController.java
+++ b/code/FXML-Calculator/src/main/java/ch/zhaw/prog2/fxmlcalculator/MainWindowController.java
@@ -8,6 +8,8 @@ import javafx.scene.control.TextField;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
+import javafx.event.ActionEvent;
+import javafx.fxml.FXML;
/**
* Controller for the MainWindow. One controller per mask (or FXML file)
@@ -17,6 +19,41 @@ import javafx.stage.Stage;
* @version 1.0
*/
public class MainWindowController {
- // please complete
+ @FXML
+ private TextField annualCost;
+
+ @FXML
+ private CheckMenuItem clearAnnualCosts;
+
+ @FXML
+ private CheckMenuItem clearInitialAmount;
+
+ @FXML
+ private CheckMenuItem clearNumberOfYears;
+
+ @FXML
+ private CheckMenuItem clearReturnInPercent;
+
+ @FXML
+ private TextField initialAmount;
+
+ @FXML
+ private TextField numberOfYears;
+
+ @FXML
+ private TextArea results;
+
+ @FXML
+ private TextField returnInPercent;
+
+ @FXML
+ void calculate(ActionEvent event) {
+
+ }
+
+ @FXML
+ void close(ActionEvent event) {
+
+ }
}
diff --git a/code/FXML-Calculator/src/main/resources/ch/zhaw/prog2/fxmlcalculator/MainWindow.fxml b/code/FXML-Calculator/src/main/resources/ch/zhaw/prog2/fxmlcalculator/MainWindow.fxml
index 5599e8b..2b2c4fa 100644
--- a/code/FXML-Calculator/src/main/resources/ch/zhaw/prog2/fxmlcalculator/MainWindow.fxml
+++ b/code/FXML-Calculator/src/main/resources/ch/zhaw/prog2/fxmlcalculator/MainWindow.fxml
@@ -1,8 +1,106 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+