Guest User

Untitled

a guest
Sep 22nd, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. public class Controller {
  2.  
  3. @FXML
  4. AnchorPane signInPane;
  5.  
  6. @FXML
  7. private TextField usernameForSignIn;
  8.  
  9. @FXML
  10. private PasswordField password;
  11.  
  12. @FXML
  13. private Button signIn;
  14.  
  15. @FXML
  16. private Button registration;
  17.  
  18. @FXML
  19. void initialize() {
  20. registration.setOnAction(event -> {
  21. signInPane.setVisible(false);
  22. SignUpController.registerPane.setVisible(true);
  23. });
  24.  
  25. signIn.setOnAction(event -> {
  26. String usernameText = usernameForSignIn.getText().trim();
  27. String passwordText = password.getText().trim();
  28.  
  29. if(!usernameText.equals("") && !passwordText.equals("")) {
  30. loginUser(usernameText, passwordText);
  31. } else {
  32. System.out.println("Empty login and/or password");
  33. }
  34.  
  35. });
  36. }
  37.  
  38. private void loginUser(String usernameText, String passwordText) {
  39. }
  40.  
  41. }
  42.  
  43. public class SignUpController {
  44.  
  45. @FXML
  46. static AnchorPane registerPane;
  47.  
  48. @FXML
  49. private TextField email;
  50.  
  51. @FXML
  52. private PasswordField pass;
  53.  
  54. @FXML
  55. private Button signUp;
  56.  
  57. @FXML
  58. private TextField fname;
  59.  
  60. @FXML
  61. private TextField lname;
  62.  
  63. @FXML
  64. private TextField username;
  65.  
  66. @FXML
  67. private RadioButton radioMale;
  68.  
  69. @FXML
  70. void initialize() {
  71.  
  72. signUp.setOnAction(event -> {
  73.  
  74. signUpNewUser();
  75.  
  76. });
  77. }
  78.  
  79. private void signUpNewUser() {
  80. DatabaseHandler databaseHandler = new DatabaseHandler();
  81.  
  82. String firstName = fname.getText();
  83. String lastName = lname.getText();
  84. String usname = username.getText();
  85. String password = pass.getText();
  86. String e_mail = email.getText();
  87. String gender = "";
  88. if(radioMale.isSelected()) {
  89. gender = "Male";
  90. } else {
  91. gender = "Female";
  92. }
  93.  
  94. User user = new User(firstName,lastName,usname,password,e_mail,gender);
  95.  
  96. databaseHandler.signUpUser(user);
  97.  
  98. }
  99. }
  100.  
  101. registration.setOnAction(event -> {
  102. registration.getScene().getWindow().hide();
  103.  
  104. FXMLLoader loader = new FXMLLoader();
  105. loader.setLocation(getClass().getResource("/sample/view/signUp.fxml"));
  106.  
  107. try {
  108. loader.load();
  109. } catch (IOException e) {
  110. e.printStackTrace();
  111. }
  112.  
  113. Parent root = loader.getRoot();
  114. Stage stage = new Stage();
  115. stage.setScene(new Scene(root));
  116. stage.showAndWait();
  117.  
  118. // signInPane.setVisible(false);
  119. });
Add Comment
Please, Sign In to add comment