title: JPasswordField how to set password
body: <p>Hello I am using a <code>JPasswordField</code> when I want to read it it is no problem with <code>getPassword</code> but what I am doing is when the Password is not set it shows a <code>InputDialog</code> where you can type in the password and then it should set the the Password in to the <code>JPasswordField</code> but when I use <code>setText</code> it does not set it and there is not method <code>setPassword()</code>. So my question is how can i set a password to a <code>JPasswordField</code>?</p>
  
  <pre><code>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);
  </code></pre>