Space von Team 22 (Nico B. Benjamin F. Lea A.)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.7 KiB

package ui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class LoginWindow implements ActionListener{
protected JFrame frame;
protected JPanel panel;
protected JLabel loginLabel;
protected JTextField loginText;
protected JLabel passwordlabel;
protected JTextField passwordText;
protected JButton loginButton;
protected JOptionPane loginSuccess;
protected JOptionPane loginFailed;
public LoginWindow(int sizeX, int sizeY) {
this.frame = new JFrame("Login");
this.frame.setSize(sizeX, sizeY);
this.panel = new JPanel();
this.frame.add(panel);
this.panel.setLayout(new BoxLayout(this.panel, BoxLayout.Y_AXIS));
this.loginLabel = new JLabel("Login:");
this.loginText = new JTextField();
this.passwordlabel = new JLabel("Password:");
this.passwordText = new JTextField();
this.loginButton = new JButton("Login");
this.loginButton.addActionListener(this);
this.panel.add(loginLabel);
this.panel.add(loginText);
this.panel.add(passwordlabel);
this.panel.add(passwordText);
this.panel.add(loginButton);
}
public void actionPerformed (ActionEvent ae) {
if(ae.getSource() == this.loginButton) {
if (loginText.getText().equals("admin") && passwordText.getText().equals("Password123!")) {
JOptionPane.showMessageDialog(frame, "Login erfolgreich", "Login Meldung", JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
} else {
JOptionPane.showMessageDialog(frame, "Login fehlgeschlagen", "Login Meldung", JOptionPane.ERROR_MESSAGE);
}
}
}
public void show() {
frame.setVisible(true);
}
}