JPasswordField
您好,当我想阅读它时,我正在使用它,这没问题,getPassword
但是我正在做的是当未设置密码时,它会显示InputDialog
您可以输入密码的位置,然后它应该将密码设置为JPasswordField
但是当我使用setText
它时没有设置它并且没有方法setPassword()
。所以我的问题是如何设置密码JPasswordField
?
String password = "";
JPasswordField passwordField = new JPasswordField();
passwordField.setEchoChar('*');
Object[] obj = {"Bitte ihr PAsswort eingeben:\n\n", passwordField};
Object stringArray[] = {"OK","Cancel"};
if (JOptionPane.showOptionDialog(null, obj, "Passwort", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, stringArray, obj) == JOptionPane.WARNING_MESSAGE)
{
password = new String(passwordField.getPassword());
}
txtFtpUser.setText(username);
panel_1.remove(txtFtpPassword);
txtFtpPassword = new JPasswordField(password);
txtFtpPassword.setBounds(10, 113, 206, 23);
panel_1.add(txtFtpPassword);