From 7c8b1fefb7aa61dd4b4efdfa238f8f6a14fc4546 Mon Sep 17 00:00:00 2001 From: Alex Rechtin Date: Fri, 14 Jan 2022 10:52:20 +0100 Subject: [PATCH] improved the createUserController.java and the create-user.fxml --- .../src/main/java/main/MainApplication.java | 8 +++-- .../main/java/users/CreateUserController.java | 29 +++++++++++++++++++ .../src/main/resources/users/create-user.fxml | 15 ++++++---- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/client/app/src/main/java/main/MainApplication.java b/client/app/src/main/java/main/MainApplication.java index 6efcaa1..84388ab 100644 --- a/client/app/src/main/java/main/MainApplication.java +++ b/client/app/src/main/java/main/MainApplication.java @@ -12,13 +12,17 @@ import java.util.Objects; public class MainApplication extends Application { @Override public void start(Stage stage) throws IOException { - FXMLLoader fxmlLoader = new FXMLLoader(MainApplication.class.getResource("main-view.fxml")); + //wieder ändern zu main-view.fxml + FXMLLoader fxmlLoader = new FXMLLoader(MainApplication.class.getResource("../users/create-user.fxml")); Scene scene = new Scene(fxmlLoader.load(), 1200, 700); scene.getStylesheets().add(Objects.requireNonNull( - MainApplication.class.getResource("main-view.css")).toExternalForm()); + //wieder ändern zu main-view.css + MainApplication.class.getResource("../users/create-user.css")).toExternalForm()); stage.setTitle("SharePlaner"); stage.setScene(scene); + //wieder löschen + stage.show(); FXMLLoader fxmlLoaderLogin = new FXMLLoader(MainApplication.class.getResource("../users/login.fxml")); Scene sceneLogin = new Scene(fxmlLoaderLogin.load(), 650, 500); diff --git a/client/app/src/main/java/users/CreateUserController.java b/client/app/src/main/java/users/CreateUserController.java index 231bd99..e5f2b4a 100644 --- a/client/app/src/main/java/users/CreateUserController.java +++ b/client/app/src/main/java/users/CreateUserController.java @@ -1,7 +1,13 @@ package users; +import javafx.event.ActionEvent; +import javafx.scene.Node; import javafx.scene.control.CheckBox; +import javafx.scene.control.Label; import javafx.scene.control.TextField; +import javafx.stage.Stage; + +import java.util.Objects; public class CreateUserController { @@ -9,4 +15,27 @@ public class CreateUserController { public TextField textPassword; public TextField textPasswordSecond; public CheckBox checkBoxIsAdmin; + public Label labelErrorName; + public Label labelErrorPw; + + protected void createUser(ActionEvent event) { + if (textName.getText().trim().isEmpty()) { + labelErrorName.setText("Bitte Usernamen eingeben!"); + labelErrorPw.setText(""); + return; + } + if (textPassword.getText().trim().isEmpty()) { + labelErrorName.setText(""); + labelErrorPw.setText("Bitte Passwort eingeben!"); + return; + } + if (Objects.equals(textPassword.getText(), textPasswordSecond.getText())){ + labelErrorName.setText(""); + labelErrorPw.setText("Passwörter stimmen nicht überein!"); + return; + } + + Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow(); + stage.close(); + } } diff --git a/client/app/src/main/resources/users/create-user.fxml b/client/app/src/main/resources/users/create-user.fxml index 837a733..29132d8 100644 --- a/client/app/src/main/resources/users/create-user.fxml +++ b/client/app/src/main/resources/users/create-user.fxml @@ -9,6 +9,7 @@ + @@ -17,19 +18,23 @@ + - + - - - - + + + + + +