Username und Passwort

This commit is contained in:
Reshad Meher 2022-12-22 02:02:19 +01:00
parent d1737b730f
commit 31b6b2cc39
3 changed files with 53 additions and 12 deletions

View File

@ -11,8 +11,13 @@ public class HelloApplication extends Application {
@Override @Override
public void start(Stage stage) throws IOException { public void start(Stage stage) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hello-view.fxml")); FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hello-view.fxml"));
Scene scene = new Scene(fxmlLoader.load(), 320, 240); /**
stage.setTitle("Hello World! von Richard"); * @autor: Reshad Meher
* Fenstergrößer
* Fenstertitle
*/
Scene scene = new Scene(fxmlLoader.load(), 480, 280);
stage.setTitle("Essen Bestellung im Kindergarten");
stage.setScene(scene); stage.setScene(scene);
stage.show(); stage.show();
} }

View File

@ -1,14 +1,34 @@
package com.bib.essensbestellungsverwaltung; package com.bib.essensbestellungsverwaltung;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.TextField;
public class HelloController { public class HelloController {
@FXML /**
private Label welcomeText; * @autor: Reshad Meher
* Username, Passwort , login
*/
@FXML @FXML
protected void onHelloButtonClick() { private TextField unsernameEingabe;
welcomeText.setText("Welcome to JavaFX Application!"); @FXML
private TextField passwortEingabe;
@FXML
private Label lblAusgabe;
@FXML
protected void onLoginButtonClick() {
String benutzerEingabe = unsernameEingabe.getText();
String kennwortEingabe = passwortEingabe.getText();
if(benutzerEingabe.contains("Reshad") && kennwortEingabe.contains("test123")){
lblAusgabe.setText("Herzlich Willkommen, " + benutzerEingabe + "!");
}else {
Alert alert = new Alert(Alert.AlertType.ERROR,
"Die Benutzername oder Passwort ist falsch");
alert.showAndWait();
}
unsernameEingabe.setText("");
passwortEingabe.setText("");
} }
} }

View File

@ -5,12 +5,28 @@
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<?import javafx.scene.control.Button?> <?import javafx.scene.control.Button?>
<VBox alignment="CENTER" spacing="20.0" xmlns:fx="http://javafx.com/fxml" <?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.control.PasswordField?>
<GridPane hgap="10.0" vgap="10.0"
xmlns:fx="http://javafx.com/fxml/1"
xmlns="http://javafx.com/javafx/11.0.2"
fx:controller="com.bib.essensbestellungsverwaltung.HelloController"> fx:controller="com.bib.essensbestellungsverwaltung.HelloController">
<padding> <padding>
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0"/> <Insets bottom="20.0" left="20.0" right="20.0" top="20.0"/>
</padding> </padding>
<Label text="Bitte geben Sie Ihre Anmeldedaten ein."
<Label fx:id="welcomeText"/> GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.rowIndex="0" />
<Button text="Hello!" onAction="#onHelloButtonClick"/> <Label text="Benutzername:"
</VBox> GridPane.columnIndex="0" GridPane.rowIndex="1" />
<TextField fx:id="unsernameEingabe"
GridPane.columnIndex="1" GridPane.rowIndex="1"/>
<Label text="Passwort:"
GridPane.columnIndex="0" GridPane.rowIndex="2" />
<PasswordField fx:id="passwortEingabe"
GridPane.columnIndex="1" GridPane.rowIndex="2"/>
<Button text="LOGIN" onAction="#onLoginButtonClick"
GridPane.columnIndex="1" GridPane.rowIndex="3" />
<Label fx:id="lblAusgabe"
GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.rowIndex="4"/>
</GridPane>