package com.example.vpr_javafx; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.scene.Node; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.control.*; import javafx.stage.Stage; 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 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 private TextField tfPhone; @FXML private PasswordField pfPassword; private Stage stage; private Scene scene; @FXML protected void OnSignInButton(ActionEvent event) throws IOException { LoginDatei file = new LoginDatei("user.txt"); HashMap<String, String> users = file.readFile(); String phoneNumber = tfPhone.getText(); String password = pfPassword.getText(); Data data = new Data("user.txt"); boolean inputValid = data.validateData(password, phoneNumber); if (users.containsKey(phoneNumber) && inputValid) { if (users.get(phoneNumber).equals(password)) { Parent root = FXMLLoader.load(getClass().getResource("MenuSelect-view.fxml")); stage = (Stage)((Node)event.getSource()).getScene().getWindow(); scene = new Scene(root); stage.setScene(scene); stage.show(); FillLabels(); } } } @FXML protected void FillLabels() { try { List<String> 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; switch (i) { case 0: lMonH1.setText(dayMenu); break; case 1: lMonD1.setText(dayMenu); break; case 2: lMonH2.setText(dayMenu); break; case 3: lMonD2.setText(dayMenu); break; case 4: lTueH1.setText(dayMenu); break; case 5: lTueD1.setText(dayMenu); break; case 6: lTueH2.setText(dayMenu); break; case 7: lTueD2.setText(dayMenu); break; case 8: lWednH1.setText(dayMenu); break; case 9: lWednD1.setText(dayMenu); break; case 10: lWednH2.setText(dayMenu); break; case 11: lWednD2.setText(dayMenu); break; case 12: lThurH1.setText(dayMenu); break; case 13: lThurD1.setText(dayMenu); break; case 14: lThurH2.setText(dayMenu); break; case 15: lThurD2.setText(dayMenu); break; case 16: lFriH1.setText(dayMenu); break; case 17: lFriD1.setText(dayMenu); break; case 18: lFriH2.setText(dayMenu); break; case 19: lFriD2.setText(dayMenu); break; } } } catch (IOException e) { e.printStackTrace(); } } }