0

I have designed this Login page in JavaFX.

enter image description here

I want when I click on Eye button next to JFXPasswordField onPressed password should be shown in Text format in PasswordField itself.

And when I released mouse button i.e. Eye button release Password should be encoded in Black dots as normal.

In swing i achieved this using

to decode -

String password = String.valueOf(txtCurrentPassword.getPassword());
txtCurrentPassword.setText(password);
txtCurrentPassword.setEchoChar((char) 0);

And to encode -

txtCurrentPassword.setEchoChar('\u2022');

Please help me to achieve this Design code using JavaFX.

Miss Chanandler Bong
  • 4,081
  • 10
  • 26
  • 36
  • [mcve] please .. – kleopatra Mar 23 '20 at 14:39
  • 1
    Interesting. This *should* be possible by subclassing `TextFieldSkin` and overriding the `maskText()` method. However, I can't see a way to trigger a repaint when the mouse is pressed on the button (or generally, when a condition changes). @Sedrick's approach in the linked question is one way, but feels a bit heavy-handed. – James_D Mar 23 '20 at 16:04
  • @James_D. https://stackoverflow.com/questions/17014012/how-to-unmask-a-javafx-passwordfield-or-properly-mask-a-textfield Uluk's answer extends `TextFieldSkinn`. I haven't tested it though. – SedJ601 Mar 23 '20 at 16:54
  • Thanks for your response I have used this thread [link](https://stackoverflow.com/questions/60049990/how-do-i-show-contents-from-the-password-field-in-javafx-using-checkbox) – Santosh Bhoir Mar 23 '20 at 17:23
  • 1
    @Sedrick I don't think that does use a subclass of `TextFieldSkin`: it just shows the old implementation of `PasswordFieldSkin` (which doesn't exist in the current version: they merged the functionality into `TextFieldSkin`). The issue still remains; I can't find a way to persuade the skin that the text needs repainting when a condition changes. – James_D Mar 23 '20 at 18:37
  • 1
    I did use of StackPane `@FXML private void onBtnViewPasswdMousePressed(MouseEvent event) { txtUnmaskPasswd.setText(txtPassword.getText()); txtPassword.clear(); txtPassword.setPromptText(""); txtUnmaskPasswd.setPromptText("Password"); txtUnmaskPasswd.toFront(); } ` – Santosh Bhoir Mar 23 '20 at 18:47

0 Answers0