Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- import javax.swing.event.*;
- /**
- *
- * Beschreibung
- *
- * @version 1.0 vom 01.05.2016
- * @author
- */
- public class Bankautomat extends JFrame {
- // Anfang Attribute
- private JTextField input_username = new JTextField();
- private JPasswordField input_password = new JPasswordField();
- private JLabel Nutzername = new JLabel();
- private JLabel Passwort = new JLabel();
- private JLabel output = new JLabel();
- private JButton input_confirm = new JButton();
- // Ende Attribute
- public Bankautomat(String title) {
- // Frame-Initialisierung
- super(title);
- setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
- int frameWidth = 232;
- int frameHeight = 154;
- setSize(frameWidth, frameHeight);
- Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
- int x = (d.width - getSize().width) / 2;
- int y = (d.height - getSize().height) / 2;
- setLocation(x, y);
- setResizable(false);
- Container cp = getContentPane();
- cp.setLayout(null);
- // Anfang Komponenten
- input_username.setBounds(104, 16, 105, 25);
- cp.add(input_username);
- input_password.setBounds(104, 48, 105, 25);
- cp.add(input_password);
- Nutzername.setBounds(8, 16, 91, 25);
- Nutzername.setText("Benutzername:");
- Nutzername.setHorizontalAlignment(SwingConstants.RIGHT);
- cp.add(Nutzername);
- Passwort.setBounds(8, 48, 91, 25);
- Passwort.setText("Passwort:");
- Passwort.setHorizontalAlignment(SwingConstants.RIGHT);
- cp.add(Passwort);
- output.setBounds(8, 80, 91, 25);
- output.setText("");
- cp.add(output);
- input_confirm.setBounds(104, 80, 105, 25);
- input_confirm.setText("Bestätigen");
- input_confirm.setMargin(new Insets(2, 2, 2, 2));
- input_confirm.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- input_confirm_ActionPerformed(evt);
- }
- });
- cp.add(input_confirm);
- // Ende Komponenten
- setVisible(true);
- } // end of public Bankautomat
- String user[][] = {{"Fred","12345678","1200"},
- {"Ted","theBear","430"},
- {"Sabine","blumentopf14","4502"},
- {"Heinrich","sge1999","240"},
- {"John","birkenh4in","75023"}};
- // Anfang Methoden
- public static void main(String[] args) {
- new Bankautomat("Bankautomat");
- } // end of main
- public void input_confirm_ActionPerformed(ActionEvent evt) {
- String username = input_password.getText();
- String password = input_password.getText();
- for (int i = 0;i < user.length;i++ ) {
- String benutzer = "Fred";
- if(username.equals(benutzer)) {
- System.out.println("Nutzer gefunden");
- }else{
- System.out.println("Nutzer nicht gefunden");
- }
- }
- } // end of input_confirm_ActionPerformed
- // Ende Methoden
- } // end of class Bankautomat
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement