如何显示 JPasswordField 的文本
How do you reveal the text of a JPasswordField
我正在 java 中制作一个身份验证应用程序,我想添加一个 JRadioButton,如果它被选中,它将允许您在 JPasswordField 中看到文本,我正在尝试弄清楚我只是想知道有什么办法吗?
来自 Java-setEchoChar()
方法的文档:
Setting a value of 0 indicates that you wish to see the text as it is typed, similar to the behavior of a standard JTextField.
所以只需使用:
second.setEchoChar((char)0);
设置和重置:
second.setEchoChar('\u2022');
默认值 EchoChar
由外观决定。为了始终与主题保持一致,最好在第一次更改之前保存默认值 EchoChar
:
char originalEchoChar = second.getEchoChar();
我正在 java 中制作一个身份验证应用程序,我想添加一个 JRadioButton,如果它被选中,它将允许您在 JPasswordField 中看到文本,我正在尝试弄清楚我只是想知道有什么办法吗?
来自 Java-setEchoChar()
方法的文档:
Setting a value of 0 indicates that you wish to see the text as it is typed, similar to the behavior of a standard JTextField.
所以只需使用:
second.setEchoChar((char)0);
设置和重置:
second.setEchoChar('\u2022');
默认值 EchoChar
由外观决定。为了始终与主题保持一致,最好在第一次更改之前保存默认值 EchoChar
:
char originalEchoChar = second.getEchoChar();