Advertisement
Guest User

Untitled

a guest
Jan 15th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.39 KB | None | 0 0
  1. package controllers;
  2.  
  3. import javafx.beans.value.ObservableValue;
  4. import javafx.event.ActionEvent;
  5. import javafx.fxml.FXML;
  6. import javafx.scene.control.PasswordField;
  7.  
  8. public class LoginController {
  9.  
  10.     private static final String ONE = "1";
  11.     private static final String TWO = "2";
  12.     private static final String THREE = "3";
  13.     private static final String FOUR = "4";
  14.     private static final String FIVE = "5";
  15.     private static final String SIX = "6";
  16.     private static final String SEVEN = "7";
  17.     private static final String EIGHT = "8";
  18.     private static final String NINE = "9";
  19.     private static final String NULL = "";
  20.  
  21.     private String password = NULL;
  22.  
  23.     @FXML
  24.     public PasswordField passwordFiled;
  25.  
  26.     public void numberOne(ActionEvent actionEvent) {
  27.         procces(this.ONE);
  28.     }
  29.  
  30.     public void numberTwo(ActionEvent actionEvent) {
  31.         procces(this.TWO);
  32.     }
  33.  
  34.     public void numberThree(ActionEvent actionEvent) {
  35.         procces(this.THREE);
  36.     }
  37.  
  38.     public void numberFour(ActionEvent actionEvent) {
  39.         procces(this.FOUR);
  40.     }
  41.  
  42.     public void numberFive(ActionEvent actionEvent) {
  43.         procces(this.FIVE);
  44.     }
  45.  
  46.     public void numberSix(ActionEvent actionEvent) {
  47.         procces(this.SIX);
  48.     }
  49.  
  50.     public void numberSeven(ActionEvent actionEvent) {
  51.         procces(this.SEVEN);
  52.     }
  53.  
  54.     public void numberEight(ActionEvent actionEvent) {
  55.         procces(this.EIGHT);
  56.     }
  57.  
  58.     public void numberNine(ActionEvent actionEvent) {
  59.         procces(this.NINE);
  60.     }
  61.  
  62.     public void confrmButton(ActionEvent actionEvent) {
  63.  
  64.     }
  65.  
  66.     public void deleteText(ActionEvent actionEvent) {
  67.         this.password = this.NULL;
  68.         passwordFiled.setPromptText(password);
  69.     }
  70.  
  71.     //Add input user sign to password
  72.     public void addSignToPassword(String anotherUserString) {
  73.         this.password = new StringBuilder(this.password).append(anotherUserString).toString();
  74.     }
  75.  
  76.     public void showPassword() {
  77.         System.out.println(this.password);
  78.     }
  79.  
  80.  
  81.     //Max 4 sings
  82.     public void checkLenghtOfPassword() {
  83.         if (this.password.length() > 4) {
  84.             this.password = password.substring(0, 4);
  85.         }
  86.     }
  87.  
  88.     public void procces(String sign){
  89.         addSignToPassword(sign);
  90.         checkLenghtOfPassword();
  91.         passwordFiled.setPromptText(password);
  92.     }
  93.  
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement