Hallo!
Ich habe folgendes Problem, beim Start meines Programms habe ich eine Passwortabfrage und ich möchte in das Feld fokus setzen klappt aber nicht habe schon alles ausprobiert.Kann mir jemand helfen wäre super.Mein PassField:
Danke
Ich habe folgendes Problem, beim Start meines Programms habe ich eine Passwortabfrage und ich möchte in das Feld fokus setzen klappt aber nicht habe schon alles ausprobiert.Kann mir jemand helfen wäre super.Mein PassField:
Java:
public boolean passwort() {
passwordField =new JPasswordField(); Passwortfensters
passwordField.setToolTipText("Geben Sie Ihr Passwort ein");
String[] Optionen = { "OK", "Abbrechen" };
int Auswahl = JOptionPane.showOptionDialog(fenster, passwordField,
"Enter password", JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE, null, Optionen, Optionen[0]);
if (Auswahl == JOptionPane.NO_OPTION) {
System.exit(0);
}
while (!String.valueOf(passwordField.getPassword()).equals(normal)
&& !String.valueOf(passwordField.getPassword()).equals(admin)) {
JOptionPane.showMessageDialog(fenster, "Falsches Passwort",
"Fehler", JOptionPane.ERROR_MESSAGE);
passwordField.setText("");
Auswahl = JOptionPane.showOptionDialog(fenster, passwordField,
"Enter password", JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE, null, Optionen, Optionen[0]);
if (Auswahl == JOptionPane.NO_OPTION) {
System.exit(0);
}
}
if (String.valueOf(passwordField.getPassword()).equals(normal)) {
passwort = true;
}
return passwort;
}
Danke