diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/LoginController.java b/src/main/java/com/bib/essensbestellungsverwaltung/LoginController.java index 4325d3b..87b5479 100644 --- a/src/main/java/com/bib/essensbestellungsverwaltung/LoginController.java +++ b/src/main/java/com/bib/essensbestellungsverwaltung/LoginController.java @@ -26,12 +26,8 @@ public class LoginController { String email = tfEmail.getText(); String password = pfPassword.getText(); if(benutzerMap.containsKey(email) && benutzerMap.containsValue(password)){ - FXMLLoader fxmlLoader = new FXMLLoader(StartViewApplication.class.getResource("menue-view.fxml")); - Scene scene = new Scene(fxmlLoader.load(), 950,480); - Stage stage = new Stage(); - stage.setTitle("Essen Bestellung im Kindergarten"); - stage.setScene(scene); - stage.show(); + // if user is worker: StartViewApplication.changeScene("workerMenu-view.fxml"); + StartViewApplication.changeScene("parentMenu-view.fxml"); }else { Alert alert = new Alert(Alert.AlertType.ERROR,"Email oder Passwort ist falsch"); alert.showAndWait(); @@ -42,12 +38,6 @@ public class LoginController { } @FXML protected void changeToSignUp() throws IOException { - FXMLLoader fxmlLoader = new FXMLLoader(StartViewApplication.class.getResource("signUp-view.fxml")); - Scene scene = new Scene(fxmlLoader.load(), 950,480); - Stage stage = new Stage(); - stage.setTitle("Essen Bestellung im Kindergarten"); - stage.setScene(scene); - stage.show(); - + StartViewApplication.changeScene("signUp-view.fxml"); } } diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/ParentMenuController.java b/src/main/java/com/bib/essensbestellungsverwaltung/ParentMenuController.java index 87c5f37..4f21d1b 100644 --- a/src/main/java/com/bib/essensbestellungsverwaltung/ParentMenuController.java +++ b/src/main/java/com/bib/essensbestellungsverwaltung/ParentMenuController.java @@ -55,8 +55,7 @@ public class ParentMenuController { @FXML public void onAusloggenClick(MouseEvent mouseEvent) throws IOException { - Parent p = FXMLLoader.load(StartViewApplication.class.getResource("workerMenu-view.fxml")); - StartViewApplication.primary.getScene().setRoot(p); + StartViewApplication.changeScene("workerMenu-view.fxml"); } private void changePage(String page) { diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/SingUpController.java b/src/main/java/com/bib/essensbestellungsverwaltung/SingUpController.java new file mode 100644 index 0000000..f6a5b6f --- /dev/null +++ b/src/main/java/com/bib/essensbestellungsverwaltung/SingUpController.java @@ -0,0 +1,11 @@ +package com.bib.essensbestellungsverwaltung; + +import javafx.event.ActionEvent; + +public class SingUpController { + public void onKontoErstellenBtClick(ActionEvent actionEvent) { + } + + public void onAnmeldenBtClick(ActionEvent actionEvent) { + } +} diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/StartViewApplication.java b/src/main/java/com/bib/essensbestellungsverwaltung/StartViewApplication.java index 1d7a126..ffc7b5a 100644 --- a/src/main/java/com/bib/essensbestellungsverwaltung/StartViewApplication.java +++ b/src/main/java/com/bib/essensbestellungsverwaltung/StartViewApplication.java @@ -7,6 +7,7 @@ package com.bib.essensbestellungsverwaltung; import javafx.application.Application; import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; @@ -14,10 +15,11 @@ import java.io.IOException; public class StartViewApplication extends Application { public static Stage primary; + @Override public void start(Stage stage) throws IOException { FXMLLoader fxmlLoader = new FXMLLoader(StartViewApplication.class.getResource("login-view.fxml")); - Scene scene = new Scene(fxmlLoader.load(), 1200,750); + Scene scene = new Scene(fxmlLoader.load(), 1200, 750); primary = stage; stage.setTitle("Essen Bestellung im Kindergarten"); stage.setScene(scene); @@ -34,4 +36,9 @@ public class StartViewApplication extends Application { //Database.deleteSample(); launch(); } + + public static void changeScene(String scene) throws IOException { + Parent p = FXMLLoader.load(StartViewApplication.class.getResource(scene)); + primary.getScene().setRoot(p); + } } \ No newline at end of file diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/WorkerMenuController.java b/src/main/java/com/bib/essensbestellungsverwaltung/WorkerMenuController.java index 1bc78ce..42d7bcb 100644 --- a/src/main/java/com/bib/essensbestellungsverwaltung/WorkerMenuController.java +++ b/src/main/java/com/bib/essensbestellungsverwaltung/WorkerMenuController.java @@ -40,6 +40,7 @@ public class WorkerMenuController { @FXML public void onWochenplanClick(MouseEvent mouseEvent) { + changePage("createFoodplan-view.fxml"); setButtonActive(wochenplanButton); } @@ -59,6 +60,7 @@ public class WorkerMenuController { @FXML public void onMahlzeitClick(MouseEvent mouseEvent) { + changePage("createFood-view.fxml"); setButtonActive(mahlzeitButton); } @@ -69,8 +71,7 @@ public class WorkerMenuController { @FXML public void onAusloggenClick(MouseEvent mouseEvent) throws IOException { - Parent p = FXMLLoader.load(StartViewApplication.class.getResource("parentMenu-view.fxml")); - StartViewApplication.primary.getScene().setRoot(p); + StartViewApplication.changeScene("parentMenu-view.fxml"); } private void changePage(String page) {