Updated create-user, css and the controller

This commit is contained in:
Alex Aleksej Rechtin 2022-01-18 12:45:18 +01:00
parent 7c8b1fefb7
commit 6e6183bf38
3 changed files with 111 additions and 26 deletions

View File

@ -1,10 +1,11 @@
package users;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleButton;
import javafx.stage.Stage;
import java.util.Objects;
@ -14,28 +15,41 @@ public class CreateUserController {
public TextField textName;
public TextField textPassword;
public TextField textPasswordSecond;
public CheckBox checkBoxIsAdmin;
public Label labelErrorName;
public Label labelErrorPw;
public ToggleButton checkButtonIsAdmin;
public TextField textLogin;
public TextField textForename;
public Label labelError;
@FXML
protected void createUser(ActionEvent event) {
if (textLogin.getText().trim().isEmpty()){
labelError.setText("Bitte Login Namen angeben");
return;
}
if (textForename.getText().trim().isEmpty()) {
labelError.setText("Bitte Vornamen eingeben!");
return;
}
if (textName.getText().trim().isEmpty()) {
labelErrorName.setText("Bitte Usernamen eingeben!");
labelErrorPw.setText("");
labelError.setText("Bitte Nachnamen eingeben!");
return;
}
if (textPassword.getText().trim().isEmpty()) {
labelErrorName.setText("");
labelErrorPw.setText("Bitte Passwort eingeben!");
labelError.setText("Bitte Passwort eingeben!");
return;
}
if (Objects.equals(textPassword.getText(), textPasswordSecond.getText())){
labelErrorName.setText("");
labelErrorPw.setText("Passwörter stimmen nicht überein!");
if (!Objects.equals(textPassword.getText(), textPasswordSecond.getText())){
labelError.setText("Passwörter stimmen nicht überein!");
return;
}
Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
stage.close();
}
@FXML
protected void abortBtnClick(ActionEvent event) {
Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
stage.close();
}
}

View File

@ -1 +1,56 @@
* {
-fx-base-background-color: #2B2D42;
-fx-base1-background-color: #525E74;
-fx-main-border-color: #B0B0B0;
-fx-main-text-color: #ffffff;
}
GridPane{
-fx-background-color: #3E415F;
-fx-padding: 20px;
-fx-font-size: 20px;
-fx-font-family: Segoe UI;
-fx-border-insets: 1;
-fx-border-color: #B0B0B0;
-fx-border-style: solid;
-fx-border-width: 2;
-fx-effect: dropshadow(three-pass-box, rgba(100, 100, 100, 1), 24, 0.5, 0, 0);
}
.mainLabel{
-fx-padding: 10px;
-fx-max-width: 400px;
-fx-min-width: 400px;
-fx-font-weight: bold;
-fx-alignment: top-center;
}
Label{
-fx-text-fill: white;
-fx-max-width: 150px;
-fx-min-width: 150px;
}
.textField{
-fx-max-width: 400px;
-fx-min-width: 400px;
}
.errorMessage{
-fx-max-width: 400px;
-fx-min-width: 400px;
}
Button{
-fx-max-width: 150px;
-fx-min-width: 150px;
}
.btnLogin{
-fx-font-weight: bold;
}

View File

@ -2,14 +2,14 @@
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.geometry.Insets?>
<GridPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="users.CreateUserController">
<columnConstraints>
<ColumnConstraints/>
<ColumnConstraints/>
<ColumnConstraints/>
<ColumnConstraints/>
<ColumnConstraints minWidth="100"/>
<ColumnConstraints minWidth="100"/>
<ColumnConstraints minWidth="100"/>
</columnConstraints>
<rowConstraints>
<RowConstraints vgrow="ALWAYS" />
@ -19,22 +19,38 @@
<RowConstraints vgrow="ALWAYS" />
<RowConstraints vgrow="ALWAYS" />
<RowConstraints vgrow="ALWAYS" />
<RowConstraints vgrow="ALWAYS" />
<RowConstraints vgrow="ALWAYS" />
<RowConstraints vgrow="ALWAYS" />
</rowConstraints>
<Label styleClass="mainLabel" GridPane.columnIndex="2" GridPane.columnSpan="2" >User anlegen</Label>
<Label styleClass="mainLabel" GridPane.columnIndex="2" >User anlegen</Label>
<Label styleClass="inputLabel" GridPane.rowIndex="1" GridPane.columnIndex="1">Name:</Label>
<Label styleClass="inputLabel" GridPane.rowIndex="3" GridPane.columnIndex="1">Passwort:</Label>
<Label styleClass="inputLabel" GridPane.rowIndex="4" GridPane.columnIndex="1">Passwort wiederholen:</Label>
<Label styleClass="inputLabel" GridPane.rowIndex="6" GridPane.columnIndex="1">Admin:</Label>
<Label styleClass="inputLabel" GridPane.rowIndex="1" GridPane.columnIndex="1">Login:</Label>
<Label styleClass="inputLabel" GridPane.rowIndex="2" GridPane.columnIndex="1">Vorname:</Label>
<Label styleClass="inputLabel" GridPane.rowIndex="3" GridPane.columnIndex="1">Nachname:</Label>
<Label styleClass="inputLabel" GridPane.rowIndex="4" GridPane.columnIndex="1">Passwort:</Label>
<Label styleClass="inputLabel" GridPane.rowIndex="5" GridPane.columnIndex="1">Passwort wiederholen:</Label>
<TextField fx:id="textName" GridPane.columnIndex="2" GridPane.rowIndex="1" maxWidth="400" minWidth="400"/>
<TextField fx:id="textPassword" GridPane.columnIndex="2" GridPane.rowIndex="3" maxWidth="400" minWidth="400"/>
<TextField fx:id="textPasswordSecond" GridPane.columnIndex="2" GridPane.rowIndex="4" maxWidth="400" minWidth="400"/>
<Label styleClass="inputLabelAdmin" GridPane.rowIndex="6" GridPane.columnIndex="1">Admin:</Label>
<CheckBox fx:id="checkBoxIsAdmin" GridPane.columnIndex="2" GridPane.rowIndex="6"/>
<TextField fx:id="textLogin" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="1" />
<TextField fx:id="textForename" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="2" />
<TextField fx:id="textName" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="3" />
<TextField fx:id="textPassword" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="4" />
<TextField fx:id="textPasswordSecond" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="5" />
<Label fx:id="labelErrorName" GridPane.columnIndex="3" GridPane.rowIndex="1"/>
<Label fx:id="labelErrorPw" GridPane.columnIndex="3" GridPane.rowIndex="3"/>
<ToggleButton fx:id="checkButtonIsAdmin" GridPane.columnIndex="2" GridPane.rowIndex="6"/>
<Label fx:id="labelError" styleClass="errorMessage" GridPane.columnIndex="2" GridPane.rowIndex="7"/>
<HBox GridPane.columnIndex="2" GridPane.rowIndex="8" alignment="CENTER_RIGHT">
<HBox.margin>
<Insets right="100" left="100"/>
</HBox.margin>
<Button onAction="#abortBtnClick">Abbrechen</Button>
<Button onAction="#createUser" styleClass="btnLogin" >Anmelden</Button>
</HBox>
</GridPane>