Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. import java.io.FileNotFoundException;
  2. import java.io.IOException;
  3. import javafx.application.Application;
  4. import javafx.geometry.Insets;
  5. import javafx.geometry.Pos;
  6. import javafx.scene.Scene;
  7. import javafx.scene.control.Button;
  8. import javafx.scene.control.Label;
  9. import javafx.scene.control.PasswordField;
  10. import javafx.scene.control.TextField;
  11. import javafx.scene.layout.GridPane;
  12. import javafx.scene.text.Font;
  13. import javafx.scene.text.FontWeight;
  14. import javafx.stage.Stage;
  15.  
  16.  
  17. public class LoginFormFX extends Application {
  18.  
  19. Stage window;
  20.  
  21. LogClass a = new LogClass();
  22. public static void main(String[] args) throws FileNotFoundException, IOException {
  23.  
  24. a.OpenFile();
  25. a.AddLog("20 ", "Justin ", "Caruso \n");
  26.  
  27. launch(args);
  28.  
  29. }
  30.  
  31. @Override
  32. public void start(Stage primaryStage) throws Exception {
  33. window = primaryStage;
  34. window.setTitle("Casino");
  35.  
  36. //GridPane with 10px padding around edge
  37. GridPane grid = new GridPane();
  38. grid.setPadding(new Insets(10));
  39. grid.setVgap(10);
  40. grid.setHgap(10);
  41. grid.setAlignment(Pos.CENTER);
  42. //Name Label - constrains use (child, column, row)
  43. Label nameLabel = new Label("Username:");
  44. GridPane.setConstraints(nameLabel, 0, 1);
  45. //Welcome Label
  46. Label welcomeLbl = new Label("Welcome");
  47. GridPane.setConstraints(welcomeLbl, 0, 0);
  48. welcomeLbl.setFont(Font.font("Tahoma", FontWeight.LIGHT, 25));
  49. //Name Input
  50. TextField nameInput = new TextField("Username");
  51. GridPane.setConstraints(nameInput, 1, 1);
  52.  
  53. //Password Label
  54. Label passLabel = new Label("Password:");
  55. GridPane.setConstraints(passLabel, 0, 2);
  56.  
  57. //Password Input
  58. PasswordField passInput = new PasswordField();
  59. passInput.setPromptText("password");
  60. GridPane.setConstraints(passInput, 1, 2);
  61.  
  62. //Login
  63. Button loginButton = new Button("Log In");
  64. GridPane.setConstraints(loginButton, 1, 3);
  65.  
  66. //Add everything to grid
  67. grid.getChildren().addAll(nameLabel, nameInput, passLabel, passInput, loginButton,welcomeLbl);
  68. //Event handler
  69. loginButton.setOnAction(e -> {
  70.  
  71. System.out.println(
  72. a.ReadFile(nameInput.getText(), passInput.getText()));
  73. a.CloseFile();
  74.  
  75. });
  76. Scene scene = new Scene(grid, 800, 600);
  77. window.setScene(scene);
  78. window.show();
  79. }
  80.  
  81.  
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement