From 3c91549e78373836225cb5e5f0f6ad3c53ec2a90 Mon Sep 17 00:00:00 2001 From: Kevin Pfannenstiel Date: Fri, 27 Jan 2023 21:51:01 +0100 Subject: [PATCH] =?UTF-8?q?Javafx=20Controller=20und=20view=20bearbeitet?= =?UTF-8?q?=20und=20einen=20Men=C3=BCplan=20erstellt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/vpr_javafx/HelloApplication.java | 4 +- .../example/vpr_javafx/HelloController.java | 184 +++++++++++++++++- .../com/example/vpr_javafx/hello-view.fxml | 104 ++++++++-- .../example/vpr_javafx/HelloController.class | Bin 655 -> 4517 bytes .../com/example/vpr_javafx/hello-view.fxml | 104 ++++++++-- 5 files changed, 366 insertions(+), 30 deletions(-) diff --git a/src/main/java/com/example/vpr_javafx/HelloApplication.java b/src/main/java/com/example/vpr_javafx/HelloApplication.java index 055f5f5..983780a 100644 --- a/src/main/java/com/example/vpr_javafx/HelloApplication.java +++ b/src/main/java/com/example/vpr_javafx/HelloApplication.java @@ -11,10 +11,12 @@ public class HelloApplication extends Application { @Override public void start(Stage stage) throws IOException { FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hello-view.fxml")); - Scene scene = new Scene(fxmlLoader.load(), 320, 240); + Scene scene = new Scene(fxmlLoader.load()); stage.setTitle("Hello!"); stage.setScene(scene); stage.show(); + HelloController controller = fxmlLoader.getController(); + controller.FillLabels(); } public static void main(String[] args) { diff --git a/src/main/java/com/example/vpr_javafx/HelloController.java b/src/main/java/com/example/vpr_javafx/HelloController.java index 74e6b65..104975b 100644 --- a/src/main/java/com/example/vpr_javafx/HelloController.java +++ b/src/main/java/com/example/vpr_javafx/HelloController.java @@ -1,14 +1,192 @@ package com.example.vpr_javafx; import javafx.fxml.FXML; +import javafx.scene.control.Alert; import javafx.scene.control.Label; +import javafx.scene.control.PasswordField; +import javafx.scene.control.TextField; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.List; public class HelloController { @FXML - private Label welcomeText; + private Label lMonH1; + @FXML + private Label lMonH2; + @FXML + private Label lMonD1; + @FXML + private Label lMonD2; + @FXML + private Label lTueH1; + @FXML + private Label lTueH2; + @FXML + private Label lTueD1; + @FXML + private Label lTueD2; + @FXML + private Label lWednH1; + @FXML + private Label lWednH2; + @FXML + private Label lWednD1; + @FXML + private Label lWednD2; + @FXML + private Label lThurH1; + @FXML + private Label lThurH2; + @FXML + private Label lThurD1; + @FXML + private Label lThurD2; + @FXML + private Label lFriH1; + @FXML + private Label lFriH2; + @FXML + private Label lFriD1; + @FXML + private Label lFriD2; @FXML - protected void onHelloButtonClick() { - welcomeText.setText("Welcome to JavaFX Application!"); + private TextField tfPhone; + @FXML + private PasswordField pfPassword; + + @FXML + protected void OnSignInButton() + { + LoginDatei file = new LoginDatei("user.txt"); + HashMap users = file.readFile(); + Alert alert = new Alert(Alert.AlertType.INFORMATION); + + if (users.containsKey(tfPhone.getText())) + { + if (users.containsValue(pfPassword.getText())) + { + alert.setContentText("Erfolgreich eingelogt"); + alert.show(); + } + else + { + alert.setContentText("Falsche Werte"); + alert.show(); + } + } + else + { + alert.setContentText("Falsche Werte"); + alert.show(); + } + } + + @FXML + protected void FillLabels() { + try { + + List menu = Files.readAllLines(Paths.get("menue.txt")); + + for (int i = 0; i < menu.size(); i++) + { + String[] parts = menu.get(i).split(";"); + + String dish = parts[1]; + String sideDish = parts[2]; + + String dayMenu = dish+"\n"+sideDish; + + if (i == 0) + { + lMonH1.setText(dayMenu); + } + else if (i == 1) + { + lMonD1.setText(dayMenu); + } + else if (i == 2) + { + lMonH2.setText(dayMenu); + } + else if (i == 3) + { + lMonD2.setText(dayMenu); + } + else if (i == 4) + { + lTueH1.setText(dayMenu); + } + else if (i == 5) + { + lTueD1.setText(dayMenu); + } + else if (i == 6) + { + lTueH2.setText(dayMenu); + } + else if (i == 7) + { + lTueD2.setText(dayMenu); + } + else if (i == 8) + { + lWednH1.setText(dayMenu); + } + else if (i == 9) + { + lWednD1.setText(dayMenu); + } + else if (i == 10) + { + lWednH2.setText(dayMenu); + } + else if (i == 11) + { + lWednD2.setText(dayMenu); + } + else if (i == 12) + { + lThurH1.setText(dayMenu); + } + else if (i == 13) + { + lThurD1.setText(dayMenu); + } + else if (i == 14) + { + lThurH2.setText(dayMenu); + } + else if (i == 15) + { + lThurD2.setText(dayMenu); + } + else if (i == 16) + { + lFriH1.setText(dayMenu); + } + else if (i == 17) + { + lFriD1.setText(dayMenu); + } + else if (i == 18) + { + lFriH2.setText(dayMenu); + } + else if (i == 19) + { + lFriD2.setText(dayMenu); + } + + } + } + catch (IOException e) { + e.printStackTrace(); + } + } } \ No newline at end of file diff --git a/src/main/resources/com/example/vpr_javafx/hello-view.fxml b/src/main/resources/com/example/vpr_javafx/hello-view.fxml index 36780df..67963be 100644 --- a/src/main/resources/com/example/vpr_javafx/hello-view.fxml +++ b/src/main/resources/com/example/vpr_javafx/hello-view.fxml @@ -1,16 +1,94 @@ - - - + + + + + - - - - - - -