Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.manoj.hello.javaFx.form;
- import javafx.application.Application;
- import javafx.geometry.Insets;
- import javafx.scene.Scene;
- import javafx.scene.control.Button;
- import javafx.scene.control.Label;
- import javafx.scene.control.TextField;
- import javafx.scene.layout.GridPane;
- import javafx.scene.layout.HBox;
- import javafx.stage.Stage;
- /**
- * Created by MANOJ on 13-Jul-17.
- */
- public class FormMainEx extends Application {
- public static void main(String[] args) {
- launch(args);
- }
- @Override
- public void start (Stage firstStage){
- firstStage.setTitle("Application Form");
- GridPane gridPane = new GridPane();
- gridPane.setPadding(new Insets(10,10,10,10));
- gridPane.setHgap(10);
- gridPane.setVgap(10);
- Label name = new Label("UserName");
- GridPane.setConstraints(name, 0,0);
- TextField userName = new TextField();
- GridPane.setConstraints(userName, 1,0);
- userName.setPromptText("ex-2626manoj");
- Label pass = new Label("Password");
- GridPane.setConstraints(pass, 0,1);
- TextField password = new TextField();
- GridPane.setConstraints(password, 1,1);
- password.setPromptText("Ex-abc@123");
- Button button = new Button("LogIn");
- // GridPane.setConstraints(button,1,2);
- Button button2 = new Button("SignUp");
- HBox hbox = new HBox(10);//10 px spacing between child nodes
- hbox.getChildren().addAll(button, button2);
- GridPane.setConstraints(hbox,1,2);
- button.setOnAction(event -> {
- boolean result2 = AlertBox.display("Alert!","are you sure to log in");
- System.out.println(result2);
- });
- button2.setOnAction(e-> {
- boolean result = ConfBox.display("Confirmation", "are you sure to sign up");
- System.out.println(result);
- });
- gridPane.getChildren().addAll(name,userName,pass,password,hbox);
- Scene scene = new Scene(gridPane,400,400);
- firstStage.setScene(scene);
- firstStage.show();
- }
- }
Add Comment
Please, Sign In to add comment