Universal Robots Forum

Input PasswordField

Working on a URCap that requires a password field. I am just using InputTextFields right now but would like to use JPasswordField setup so I can setEchoChar. I do not know if it is possible with just the standard InputTextField but when I try to use JPasswordField it doesn’t initialize the input id with the variable.

Essentially I just want to hide the inputted characters with a masked character just like a typical password field.

to my knowledge that’s not possible. You cannot replace InputTextField by JPasswordField.
But I can suggest a workaround:
In your *NodeContribution you could read the text (in the OnInputEvent) and store it in the model and overwrite the textfield directly with “*****”.

@Input(id = “PasswdTextField”)
public void onInputPwd(InputEvent event)
{
if (event.getEventType() == InputEvent.EventType.ON_CHANGE)
{
PwdVar = PasswdTextField.getText();
PasswdTextField.setText("****");
}
}

Note, that in this case, the password is stored readable in the model, so you might want to use some kind of en-/decryption for the stored value in the model.

2 Likes

Thank you this is a good work around that I can implement!