|
@ -0,0 +1,63 @@ |
|
|
|
|
|
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); |
|
|
|
|
|
frame.setVisible(false); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
JOptionPane.showMessageDialog(frame, "Login fehlgeschlagen", "Login Meldung", JOptionPane.ERROR_MESSAGE); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void show() { |
|
|
|
|
|
frame.setVisible(true); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |