Guest User

Untitled

a guest
Jul 18th, 2017
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. package com.manoj.hello.javaFx.form;
  2.  
  3. import javafx.application.Application;
  4. import javafx.geometry.Insets;
  5. import javafx.scene.Scene;
  6. import javafx.scene.control.Button;
  7. import javafx.scene.control.Label;
  8. import javafx.scene.control.TextField;
  9. import javafx.scene.layout.GridPane;
  10. import javafx.scene.layout.HBox;
  11. import javafx.stage.Stage;
  12.  
  13. /**
  14. * Created by MANOJ on 13-Jul-17.
  15. */
  16. public class FormMainEx extends Application {
  17. public static void main(String[] args) {
  18. launch(args);
  19. }
  20. @Override
  21. public void start (Stage firstStage){
  22. firstStage.setTitle("Application Form");
  23.  
  24. GridPane gridPane = new GridPane();
  25. gridPane.setPadding(new Insets(10,10,10,10));
  26. gridPane.setHgap(10);
  27. gridPane.setVgap(10);
  28.  
  29. Label name = new Label("UserName");
  30. GridPane.setConstraints(name, 0,0);
  31.  
  32. TextField userName = new TextField();
  33. GridPane.setConstraints(userName, 1,0);
  34. userName.setPromptText("ex-2626manoj");
  35.  
  36. Label pass = new Label("Password");
  37. GridPane.setConstraints(pass, 0,1);
  38.  
  39. TextField password = new TextField();
  40. GridPane.setConstraints(password, 1,1);
  41. password.setPromptText("Ex-abc@123");
  42.  
  43. Button button = new Button("LogIn");
  44. // GridPane.setConstraints(button,1,2);
  45.  
  46.  
  47. Button button2 = new Button("SignUp");
  48.  
  49. HBox hbox = new HBox(10);//10 px spacing between child nodes
  50. hbox.getChildren().addAll(button, button2);
  51. GridPane.setConstraints(hbox,1,2);
  52.  
  53. button.setOnAction(event -> {
  54. boolean result2 = AlertBox.display("Alert!","are you sure to log in");
  55. System.out.println(result2);
  56. });
  57.  
  58. button2.setOnAction(e-> {
  59. boolean result = ConfBox.display("Confirmation", "are you sure to sign up");
  60. System.out.println(result);
  61. });
  62.  
  63.  
  64. gridPane.getChildren().addAll(name,userName,pass,password,hbox);
  65.  
  66.  
  67. Scene scene = new Scene(gridPane,400,400);
  68.  
  69.  
  70.  
  71. firstStage.setScene(scene);
  72. firstStage.show();
  73.  
  74.  
  75. }
  76. }
Add Comment
Please, Sign In to add comment