Guest User

Untitled

a guest
Dec 2nd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package cse327_studentadvisingsystem_javafx;
  7.  
  8. import javafx.geometry.Insets;
  9. import javafx.application.Application;
  10. import javafx.event.ActionEvent;
  11. import javafx.event.EventHandler;
  12. import javafx.geometry.Pos;
  13. import javafx.scene.Scene;
  14. import javafx.scene.control.Button;
  15. import javafx.scene.control.Label;
  16. import javafx.scene.control.PasswordField;
  17. import javafx.scene.control.TextField;
  18. import javafx.scene.layout.GridPane;
  19. import javafx.scene.layout.HBox;
  20. import javafx.scene.paint.Color;
  21. import javafx.scene.text.Font;
  22. import javafx.scene.text.FontWeight;
  23. import javafx.scene.text.Text;
  24. import javafx.stage.Stage;
  25.  
  26. /**
  27. *
  28. * @author muhib
  29. */
  30. public class LogIn extends Application {
  31.  
  32. @Override
  33. public void start(Stage primaryStage) {
  34. primaryStage.setTitle("LogIn");
  35. //create a GridPanel Layout
  36. GridPane login_grid = new GridPane();
  37. login_grid.setAlignment(Pos.CENTER);
  38. login_grid.setHgap(10); //horizontal gap between components
  39. login_grid.setVgap(10);
  40. login_grid.setPadding(new Insets(25, 25, 25, 25));
  41.  
  42. Text scenetitle = new Text("Welcome");
  43. scenetitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));
  44. login_grid.add(scenetitle, 0, 0, 2, 1);
  45.  
  46. /*
  47. The grid.add() method adds the scenetitle variable to the layout grid.
  48. The numbering for columns and rows in the grid starts at zero, and
  49. scenetitle is added in column 0, row 0. The last two arguments of
  50. the grid.add() method set the column span to 2 and the row span to 1.
  51. */
  52.  
  53. Label userName = new Label("User Name:");
  54. login_grid.add(userName, 0, 1);
  55.  
  56. TextField userTextField = new TextField();
  57. login_grid.add(userTextField, 1, 1);
  58.  
  59. Label pw = new Label("Password:");
  60. login_grid.add(pw, 0, 2);
  61.  
  62. PasswordField pwBox = new PasswordField();
  63. login_grid.add(pwBox, 1, 2);
  64.  
  65. //add button and HBox pane
  66. Button login_btn = new Button("Log in");
  67. HBox hblogin_btn = new HBox(10);
  68. hblogin_btn.setAlignment(Pos.BOTTOM_RIGHT);
  69. hblogin_btn.getChildren().add(login_btn);
  70. login_grid.add(hblogin_btn, 1, 4);
  71.  
  72. final Text actiontarget = new Text();
  73. login_grid.add(actiontarget, 1, 6);
  74.  
  75. login_btn.setOnAction(new EventHandler<ActionEvent>() {
  76. @Override
  77. public void handle(ActionEvent e) {
  78. actiontarget.setFill(Color.FIREBRICK);
  79. actiontarget.setText("Sign in button pressed");
  80. }
  81. });
  82.  
  83. Scene scene = new Scene(login_grid);
  84. primaryStage.setScene(scene);
  85.  
  86. primaryStage.show();
  87. }
  88. }
Add Comment
Please, Sign In to add comment