Registrierung ergänzt und Kommentar hinzugefügt

This commit is contained in:
Kevin Maier 2023-01-31 18:36:32 +01:00
parent d222db8816
commit 9aa49d7dfe
2 changed files with 45 additions and 13 deletions

View File

@ -94,6 +94,14 @@ public class HelloController {
public TextField tfName; public TextField tfName;
@FXML @FXML
public TextField tfChild; public TextField tfChild;
@FXML
public TextField tfStreet;
@FXML
public TextField tfHouseNumber;
@FXML
public TextField tfPostalCode;
@FXML
public TextField tfCity;
@FXML @FXML
private PasswordField pfPassword; private PasswordField pfPassword;
@ -279,6 +287,12 @@ public class HelloController {
+ "8: Konservierungsstoff"); + "8: Konservierungsstoff");
} }
/**
* ToRegistration() ruft die Registration-View auf, sobald man auf den Registrierungs-Button klickt
* @param event
* @throws IOException
* @author Kevin Maier
*/
@FXML @FXML
protected void ToRegistration(ActionEvent event) throws IOException protected void ToRegistration(ActionEvent event) throws IOException
{ {
@ -289,6 +303,12 @@ public class HelloController {
stage.show(); stage.show();
} }
/**
* OnRegistrationButton() lässt einen neuen Nutzer anlegen
* @param event
* @throws IOException
* @author Kevin Maier
*/
@FXML @FXML
protected void OnRegistrationButton(ActionEvent event) throws IOException protected void OnRegistrationButton(ActionEvent event) throws IOException
{ {
@ -302,7 +322,7 @@ public class HelloController {
else if (validData.validateData(tfPhone, pfPassword, this)) else if (validData.validateData(tfPhone, pfPassword, this))
{ {
try (FileWriter writer = new FileWriter("user.txt")){ try (FileWriter writer = new FileWriter("user.txt")){
writer.write(tfName.getText() + ";" + tfPhone.getText() + ";" + tfChild.getText() + ";" + pfPassword.getText()); writer.write(tfName.getText() + ";" + tfStreet.getText() + " " + tfHouseNumber.getText() + "," + tfPostalCode + " " + tfCity.getText() + ";" + tfPhone.getText() + ";" + tfChild.getText() + ";" + pfPassword.getText());
writer.flush(); writer.flush();
} }
catch (IOException e) catch (IOException e)

View File

@ -1,14 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<AnchorPane prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.14-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.vpr_javafx.HelloController"> <AnchorPane prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.14-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.vpr_javafx.HelloController">
<children> <children>
<GridPane layoutX="100.0" layoutY="75.0" prefHeight="250.0" prefWidth="400.0"> <GridPane layoutX="50.0" layoutY="62.0" prefHeight="275.0" prefWidth="500.0">
<columnConstraints> <columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="153.0" minWidth="10.0" prefWidth="89.8" /> <ColumnConstraints hgrow="SOMETIMES" maxWidth="153.0" minWidth="10.0" prefWidth="85.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="261.0" minWidth="10.0" prefWidth="226.2" /> <ColumnConstraints hgrow="SOMETIMES" maxWidth="261.0" minWidth="10.0" prefWidth="200.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="261.0" minWidth="10.0" prefWidth="200.0" />
</columnConstraints> </columnConstraints>
<rowConstraints> <rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
@ -17,17 +19,27 @@
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints> </rowConstraints>
<children> <children>
<Label text="Voller Name: " /> <Label text="Name" />
<Label text="Handynummer: " GridPane.rowIndex="1" /> <Label text="Handynummer" GridPane.rowIndex="1" />
<Label prefWidth="95.0" text="Passwort: " GridPane.rowIndex="2" /> <Label prefWidth="95.0" text="Passwort: " GridPane.rowIndex="2" />
<Label text="Kind: " GridPane.rowIndex="3" /> <Label text="Kind:" GridPane.rowIndex="5" />
<Button mnemonicParsing="false" onAction="#OnRegistrationButton" prefHeight="26.0" prefWidth="90.0" text="Abschicken" translateX="100.0" GridPane.columnIndex="1" GridPane.rowIndex="5" /> <Label text="Straße" GridPane.rowIndex="3" />
<PasswordField fx:id="pfPassword" GridPane.columnIndex="1" GridPane.rowIndex="2" /> <Label text="Ort" GridPane.rowIndex="4" />
<TextField fx:id="tfName" GridPane.columnIndex="1" /> <Button mnemonicParsing="false" onAction="#OnRegistrationButton" prefHeight="26.0" prefWidth="90.0" text="Abschicken" translateX="100.0" GridPane.columnIndex="1" GridPane.rowIndex="7" />
<TextField fx:id="tfPhone" GridPane.columnIndex="1" GridPane.rowIndex="1" /> <PasswordField fx:id="pfPassword" promptText="Passwort" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<TextField fx:id="tfChild" GridPane.columnIndex="1" GridPane.rowIndex="3" /> <TextField fx:id="tfName" promptText="Voller Name" GridPane.columnIndex="1" />
<TextField fx:id="tfPhone" promptText="Handynummer" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<TextField fx:id="tfChild" promptText="Kind" GridPane.columnIndex="1" GridPane.rowIndex="5" />
<TextField GridPane.columnIndex="1" GridPane.rowIndex="4" />
<TextField fx:id="tfStreet" prefWidth="254.0" promptText="Straße" GridPane.columnIndex="1" GridPane.rowIndex="3" />
<TextField fx:id="tfHouseNumber" prefWidth="123.0" promptText="Hausnummer" GridPane.columnIndex="2" GridPane.rowIndex="3"/>
<TextField fx:id="tfPostalCode" promptText="Postleitzahl" GridPane.columnIndex="1" GridPane.rowIndex="4" />
<TextField fx:id="tfCity" promptText="Ort" GridPane.columnIndex="2" GridPane.rowIndex="4" />
</children> </children>
</GridPane> </GridPane>
</children> </children>