improved the createUserController.java and the create-user.fxml

This commit is contained in:
2022-01-14 10:52:20 +01:00
parent 226255f75a
commit 7c8b1fefb7
3 changed files with 45 additions and 7 deletions

View File

@@ -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);

View File

@@ -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();
}
}