- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPassWordPane.java
More file actions
Latest commit
138 lines (114 loc) · 4.71 KB
/
Copy pathPassWordPane.java
File metadata and controls
138 lines (114 loc) · 4.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
importjavafx.event.ActionEvent;
importjavafx.geometry.HPos;
importjavafx.geometry.Pos;
importjavafx.scene.control.Label;
importjavafx.scene.control.TextField;
importjavafx.scene.layout.GridPane;
importjavafx.scene.paint.Color;
importjavafx.scene.text.Font;
/**
* This builds the scene and holds the event handelers
* @author Thomas Jessop
* @version 1.2
* @since 2018-09-30
*
* @param name this is the textbox for name input
* @param date this is the textbox for date input
* @param result this label is used both for displaying the created password and the empty textbox methods
*/
publicclassPassWordPaneextendsGridPane {
privateTextFieldname;
privateTextFielddate;
privateLabelresult;
/**
* builds the scene
* @param font the font size determinate
* @param tileLabel The app's tile
* @param nameLabel the prompt for the name
* @param dateLabel the prompt for the date
* @param yourPasswd the label indocating the nature of the result label
*
*/
publicPassWordPane(){
Fontfont = newFont(18);
LabeltileLabel = newLabel("Thomas's password genorator");
GridPane.setHalignment(tileLabel, HPos.CENTER);
tileLabel.setFont(font);
tileLabel.setTextFill(Color.WHITE);
LabelnameLabel = newLabel("Please give your name :");
nameLabel.setFont(font);
GridPane.setHalignment(nameLabel, HPos.RIGHT);
nameLabel.setTextFill(Color.WHITE);
LabeldateLabel = newLabel("Please give a six digit date :");
dateLabel.setFont(font);
GridPane.setHalignment(dateLabel, HPos.RIGHT);
dateLabel.setTextFill(Color.WHITE);
name = newTextField();
name.setAlignment(Pos.CENTER);
name.setPrefWidth(100);
name.setOnAction(this::passwdGenName);
date =newTextField();
date.setAlignment(Pos.CENTER);
date.setPrefWidth(100);
date.setOnAction(this::passwdGenDate);
LabelyourPasswd = newLabel("Your new Password is :");
GridPane.setHalignment(yourPasswd, HPos.RIGHT);
yourPasswd.setFont(font);
yourPasswd.setTextFill(Color.WHITE);
result = newLabel("---");
result.setFont(font);
GridPane.setHalignment(result, HPos.CENTER);
result.setTextFill(Color.WHITESMOKE);
setAlignment(Pos.CENTER);
setHgap(20);
setVgap(10);
setStyle("-fx-background-color: blue");
add(tileLabel, 0, 0);
add(nameLabel, 0, 2);
add(name, 1, 2);
add(dateLabel, 0, 3);
add(date, 1, 3);
add(yourPasswd, 0, 4);
add(result, 1, 4);
}//construtor PassWordPane
/**
* the actionevent handeler tied to the name textbox.
*It creates a password and sets result to the new password, unless date is empty then result is set to an error prompt
* @param event an event object
*@param pName takes the contents of name and stores it in a string
*@param pDate takes the contents of date and stores it in a string
@param pResult take the first two char of pName, a '.', a digit random number and the last four char of pDate concatinating them into a single string.
*/
publicvoidpasswdGenName(ActionEventevent){
if (date.getText().isEmpty()) {
result.setText("Please give a date");
result.setUnderline(true);
}else{
StringpName = name.getText();
StringpDate = date.getText();
StringpResult = pName.substring(0, 2) + "." + (int) ( Math.random() * 99) +
pDate.substring(pDate.length() -4);
result.setText(pResult);
}
}//passwdGenName
/**
* the actionevent handeler tied to the date textbox.
*It creates a password and sets result to the new password, unless name is empty then result is set to an error prompt
* @param event an event object
*@param pName takes the contents of name and stores it in a string
*@param pDate takes the contents of date and stores it in a string
@param pResult take the first two char of pName, a '.', a digit random number and the last four char of pDate concatinating them into a single string.
*/
publicvoidpasswdGenDate(ActionEventevent){
if (name.getText().isEmpty() ) {
result.setText("Please give your name");
result.setUnderline(true);
} else {
StringpName = name.getText();
StringpDate = date.getText();
StringpResult = pName.substring(0, 2) + "." + (int) ( Math.random() * 99) +
pDate.substring(pDate.length() -4);
result.setText(pResult);
}
}//passwdGenDate
}// class PasswordPane