<\/span><\/h2>\n\n\n\n\n\/*\n * To change this license header, choose License Headers in Project Properties.\n * To change this template file, choose Tools | Templates\n * and open the template in the editor.\n *\/\npackage javafxloginprogram;\n\nimport javafx.application.Application;\nimport javafx.event.ActionEvent;\nimport javafx.event.EventHandler;\nimport javafx.geometry.Insets;\nimport javafx.scene.Scene;\nimport javafx.scene.control.Alert;\nimport javafx.scene.control.Alert.AlertType;\nimport javafx.scene.control.Button;\nimport javafx.scene.control.Label;\nimport javafx.scene.control.TextField;\nimport javafx.scene.layout.StackPane;\nimport javafx.scene.layout.VBox;\nimport javafx.stage.Stage;\n\n\/**\n *\n * @author HP\n *\/\npublic class JavaFXLoginProgram extends Application {\n\n private StackPane root = new StackPane();\n \/\/Final Username.\n static final String USERNAME = "Admin";\n \/\/Final Password.\n static final String PASSWORD = "1234";\n \/\/Username Textfield.\n TextField usernameTxt = new TextField();\n \/\/Password Textfield.\n TextField passwordTxt = new TextField();\n \/\/Declaring stage.\n private Stage stage;\n\n @Override\n public void start(Stage primaryStage) {\n VBox vBox = new VBox();\n Button button = new Button("LOGIN");\n vBox.setSpacing(8);\n vBox.setPadding(new Insets(10, 10, 10, 10));\n vBox.getChildren().addAll(\n new Label("Username"),\n usernameTxt = new TextField(),\n new Label("Password"),\n passwordTxt,\n button);\n\n root.getChildren().addAll(vBox);\n\n button.setOnAction(new EventHandler<ActionEvent>() {\n\n @Override\n public void handle(ActionEvent event) {\n \/\/Printing On the console.\n System.out.println(usernameTxt.getText() + " " + passwordTxt.getText());\n \/\/If Credentials Are Correct.\n if (usernameTxt.getText().equals(USERNAME) && passwordTxt.getText().equals(PASSWORD)) {\n \/\/Open New Stage.\n stage = new Stage();\n StackPane stackPane = new StackPane();\n stage.setScene(new Scene(stackPane, 200, 200));\n stage.show();\n } else {\n \/\/Error Dialog Box\/Alert!.\n System.out.println("Failed");\n Alert alert = new Alert(AlertType.WARNING);\n alert.setTitle("Warning Dialog");\n alert.setHeaderText("Failed");\n alert.setContentText("Try Again!");\n\n alert.showAndWait();\n\n }\n }\n });\n\n Scene scene = new Scene(root, 300, 250);\n\n primaryStage.setTitle("Hello World!");\n primaryStage.setScene(scene);\n primaryStage.show();\n\n }\n\n \/**\n * @param args the command line arguments\n *\/\n public static void main(String[] args) {\n launch(args);\n }\n\n}\n\n\n<\/pre>\n\n\n\n<\/p>\n\n\n\n
<\/span>OUTPUT SCREENSHOTS<\/span><\/h2>\n\n\n\n <\/figure>\n\n\n\n <\/figure>\n\n\n\n <\/figure>\n\n\n\n <\/figure>\n\n\n\n <\/figure>\n\n\n\n<\/p>\n","protected":false},"excerpt":{"rendered":"
JavaFX Login Program GUI (graphical user interface). This is an example of javaFX login program. Copy this code to you IDE and use Username –…<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/mauricemuteti.info\/wp-json\/wp\/v2\/posts\/4286"}],"collection":[{"href":"https:\/\/mauricemuteti.info\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mauricemuteti.info\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mauricemuteti.info\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mauricemuteti.info\/wp-json\/wp\/v2\/comments?post=4286"}],"version-history":[{"count":0,"href":"https:\/\/mauricemuteti.info\/wp-json\/wp\/v2\/posts\/4286\/revisions"}],"wp:attachment":[{"href":"https:\/\/mauricemuteti.info\/wp-json\/wp\/v2\/media?parent=4286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mauricemuteti.info\/wp-json\/wp\/v2\/categories?post=4286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mauricemuteti.info\/wp-json\/wp\/v2\/tags?post=4286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}