@@ -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