Skip to content

Commit 08e22a6

Browse files
committed
Implemented #24 idea requested by @Kubis10
1 parent 9b7c14a commit 08e22a6

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

src/main/java/me/goral/keepmypassworddesktop/controllers/LoggedController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ private void initialize() {
4444
showBtn.getStyleClass().add("show");
4545
addButton.setWrapText(true);
4646
removeButton.setWrapText(true);
47+
4748
genPwd.setWrapText(true);
4849
ImageView imageView = new ImageView(MainApp.class.getResource("/me/goral/keepmypassworddesktop/images/settings-128.png").toExternalForm());
4950
settingsButton.setGraphic(imageView);

src/main/java/me/goral/keepmypassworddesktop/controllers/MainAppController.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,22 @@ protected void onLoginButtonClick() {
7878

7979
TextField username = new TextField();
8080
username.setPromptText("Username");
81+
TextField tf = new TextField();
82+
tf.setManaged(false);
83+
tf.setVisible(false);
8184
PasswordField password = new PasswordField();
8285
password.setPromptText("Password");
86+
87+
CheckBox checkBox = new CheckBox();
88+
89+
tf.managedProperty().bind(checkBox.selectedProperty());
90+
tf.visibleProperty().bind(checkBox.selectedProperty());
91+
92+
password.managedProperty().bind(checkBox.selectedProperty().not());
93+
password.visibleProperty().bind(checkBox.selectedProperty().not());
94+
95+
tf.textProperty().bindBidirectional(password.textProperty());
96+
8397
Label pwdCheck = new Label("No password");
8498
pwdCheck.setTextFill(Color.web("#b3b3b3"));
8599

@@ -93,6 +107,8 @@ protected void onLoginButtonClick() {
93107
grid.add(username, 1, 0);
94108
grid.add(new Label("Password"), 0, 1);
95109
grid.add(password, 1, 1);
110+
grid.add(tf, 1,1);
111+
grid.add(checkBox,2,1);
96112
if (!login) {
97113
grid.add(pwdCheck, 1, 2);
98114
}
@@ -229,8 +245,22 @@ protected void onLoginButtonClick(String unameString, String passwordString) {
229245

230246
TextField username = new TextField();
231247
username.setText(unameString);
248+
TextField tf = new TextField();
249+
tf.setManaged(false);
250+
tf.setVisible(false);
232251
PasswordField password = new PasswordField();
233252
password.setText(passwordString);
253+
254+
CheckBox checkBox = new CheckBox();
255+
256+
tf.managedProperty().bind(checkBox.selectedProperty());
257+
tf.visibleProperty().bind(checkBox.selectedProperty());
258+
259+
password.managedProperty().bind(checkBox.selectedProperty().not());
260+
password.visibleProperty().bind(checkBox.selectedProperty().not());
261+
262+
tf.textProperty().bindBidirectional(password.textProperty());
263+
234264
Label pwdCheck = new Label("No password");
235265
pwdCheck.setTextFill(Color.web("#b3b3b3"));
236266

@@ -244,6 +274,8 @@ protected void onLoginButtonClick(String unameString, String passwordString) {
244274
grid.add(username, 1, 0);
245275
grid.add(new Label("Password"), 0, 1);
246276
grid.add(password, 1, 1);
277+
grid.add(tf, 1,1);
278+
grid.add(checkBox,2,1);
247279
if (!login) {
248280
grid.add(pwdCheck, 1, 2);
249281
}

0 commit comments

Comments
 (0)