Kennwort mit JOptionPane abfragen

JPasswordField jPasswordField = new JPasswordField();
Object[] message = {"Kennwort:\n", jPasswordField};
           
int a = JOptionPane.showConfirmDialog(null, message,
       "Kennwort eingeben", JOptionPane.OK_CANCEL_OPTION,
       JOptionPane.QUESTION_MESSAGE);

if(a == JOptionPane.OK_OPTION) {
   String pwd = new String(jPasswordField.getPassword());
   System.out.println("Kennwort: " + pwd);
}

This entry was posted in Java. Bookmark the permalink.

Hinterlasse eine Antwort

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *

*

Du kannst folgende HTML-Tags benutzen: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>