Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.emilkraft.tut1;
- import javax.swing.JOptionPane;
- public class Authenticator {
- public static void main(String args[]) {
- /*
- * Die Strings
- */
- String username = JOptionPane.showInputDialog("Benutzername:");
- String password = JOptionPane.showInputDialog("Passwort:");
- /*
- * If
- * Du musst natürlich nicht so wie ich schreiben!
- * NUR wegen der Übersicht!
- */
- if(
- username != null &&
- password != null &&
- (
- /*
- * Die Benutzer mit Passwörtern
- */
- //Benutzer1
- (username.equals("bspname") &&
- //Passwort1
- password.equals("bsppassword")) ||
- //Benutzer2
- (username.equals("bspname2") &&
- //Passwort2
- password.equals("bsppassword2"))
- )
- )
- {
- //Meldung nach richtigem Namen und Passwort
- JOptionPane.showMessageDialog(null, "Bekannter Benutzer! Zugang gewährt!");
- } else {
- //Meldung nach falschem Namen und Passwort
- JOptionPane.showMessageDialog(null, "Unbekannter Benutzer! Zugang verweigert!");
- }
- /*
- * TODO: Eigenen Code hinzufügen
- * z.B. Nach richtigem Namen und Passwort einen JFrame mit Inhalt öffnen (Nur ein Beispiel!)
- */
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement