import javafx.application.Application; import javafx.geometry.Insets; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.TextField; import javafx.scene.control.PasswordField; import javafx.scene.control.Alert; import javafx.scene.layout.VBox; public class App extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) throws Exception { TextField userInput = new TextField(); PasswordField passInput = new PasswordField(); passInput.setPromptText("jelszó"); Button loginButton = new Button("Belépés"); Alert alert = new Alert(Alert.AlertType.INFORMATION); loginButton.setOnAction(e -> { String user = userInput.getText(); String pass = passInput.getText(); System.out.printf("|%s|\n",user); System.out.printf("|%s|\n", pass); String msgStr = ""; if(user.equals("janos") && pass.equals("titok")) { msgStr = "Azonosítás OK"; }else { msgStr = "Hiba! Azonosítás sikertelen!"; } alert.setContentText(msgStr); alert.showAndWait(); }); VBox vbox = new VBox(); vbox.setPadding(new Insets(10, 10, 10, 10)); vbox.setSpacing(10); vbox.getChildren().add(userInput); vbox.getChildren().add(passInput); vbox.getChildren().add(loginButton); Scene scene = new Scene(vbox, 300, 250); primaryStage.setScene(scene); primaryStage.show(); } }