Advertisement
Guest User

Untitled

a guest
May 1st, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.01 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import javax.swing.*;
  4. import javax.swing.event.*;
  5.  
  6. /**
  7.   *
  8.   * Beschreibung
  9.   *
  10.   * @version 1.0 vom 01.05.2016
  11.   * @author
  12.   */
  13.  
  14. public class Bankautomat extends JFrame {
  15.   // Anfang Attribute
  16.   private JTextField input_username = new JTextField();
  17.   private JPasswordField input_password = new JPasswordField();
  18.   private JLabel Nutzername = new JLabel();
  19.   private JLabel Passwort = new JLabel();
  20.   private JLabel output = new JLabel();
  21.   private JButton input_confirm = new JButton();
  22.   // Ende Attribute
  23.  
  24.   public Bankautomat(String title) {
  25.     // Frame-Initialisierung
  26.     super(title);
  27.     setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  28.     int frameWidth = 232;
  29.     int frameHeight = 154;
  30.     setSize(frameWidth, frameHeight);
  31.     Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
  32.     int x = (d.width - getSize().width) / 2;
  33.     int y = (d.height - getSize().height) / 2;
  34.     setLocation(x, y);
  35.     setResizable(false);
  36.     Container cp = getContentPane();
  37.     cp.setLayout(null);
  38.     // Anfang Komponenten
  39.    
  40.     input_username.setBounds(104, 16, 105, 25);
  41.     cp.add(input_username);
  42.     input_password.setBounds(104, 48, 105, 25);
  43.     cp.add(input_password);
  44.     Nutzername.setBounds(8, 16, 91, 25);
  45.     Nutzername.setText("Benutzername:");
  46.     Nutzername.setHorizontalAlignment(SwingConstants.RIGHT);
  47.     cp.add(Nutzername);
  48.     Passwort.setBounds(8, 48, 91, 25);
  49.     Passwort.setText("Passwort:");
  50.     Passwort.setHorizontalAlignment(SwingConstants.RIGHT);
  51.     cp.add(Passwort);
  52.     output.setBounds(8, 80, 91, 25);
  53.     output.setText("");
  54.     cp.add(output);
  55.     input_confirm.setBounds(104, 80, 105, 25);
  56.     input_confirm.setText("Bestätigen");
  57.     input_confirm.setMargin(new Insets(2, 2, 2, 2));
  58.     input_confirm.addActionListener(new ActionListener() {
  59.       public void actionPerformed(ActionEvent evt) {
  60.         input_confirm_ActionPerformed(evt);
  61.       }
  62.     });
  63.     cp.add(input_confirm);
  64.     // Ende Komponenten
  65.    
  66.     setVisible(true);
  67.   } // end of public Bankautomat
  68.   String user[][] = {{"Fred","12345678","1200"},
  69.                      {"Ted","theBear","430"},
  70.                      {"Sabine","blumentopf14","4502"},
  71.                      {"Heinrich","sge1999","240"},
  72.                      {"John","birkenh4in","75023"}};
  73.        
  74.   // Anfang Methoden
  75.  
  76.   public static void main(String[] args) {
  77.     new Bankautomat("Bankautomat");
  78.   } // end of main
  79.  
  80.   public void input_confirm_ActionPerformed(ActionEvent evt) {
  81.     String username = input_password.getText();
  82.     String password = input_password.getText();
  83.     for (int i = 0;i < user.length;i++ ) {
  84.       String benutzer = "Fred";
  85.       if(username.equals(benutzer)) {
  86.         System.out.println("Nutzer gefunden");
  87.       }else{
  88.         System.out.println("Nutzer nicht gefunden");
  89.        
  90.        
  91.       }
  92.     }
  93.    
  94.   } // end of input_confirm_ActionPerformed
  95.    
  96.     // Ende Methoden
  97. } // end of class Bankautomat
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement