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.
59 lines
1.8 KiB
59 lines
1.8 KiB
package ui;
|
|
|
|
import java.awt.event.ActionEvent;
|
|
import java.awt.event.ActionListener;
|
|
|
|
import javax.swing.JButton;
|
|
import javax.swing.JFrame;
|
|
import javax.swing.JLabel;
|
|
import javax.swing.JOptionPane;
|
|
import javax.swing.JPanel;
|
|
import javax.swing.JTextField;
|
|
|
|
public class LoginWIndow implements ActionListener {
|
|
JPanel panel = new JPanel();
|
|
JFrame frame = new JFrame();
|
|
|
|
JLabel labelLogin = new JLabel("login");
|
|
JTextField textLogin = new JTextField(null, 20);
|
|
String textFieldValueLogin = "";
|
|
|
|
JLabel labelPasswort = new JLabel("passwort");
|
|
JTextField textPasswort = new JTextField(null, 20);
|
|
String textFieldValuePasswort = "";
|
|
|
|
JButton button = new JButton("Confirm");
|
|
|
|
public LoginWIndow() {
|
|
this.frame.setSize(250, 300);
|
|
this.frame.setContentPane(panel);
|
|
this.button.addActionListener(this);
|
|
|
|
this.panel.add(this.labelLogin);
|
|
this.panel.add(this.textLogin);
|
|
this.panel.add(this.labelPasswort);
|
|
this.panel.add(this.textPasswort);
|
|
this.panel.add(this.button);
|
|
this.frame.setVisible(true);
|
|
|
|
}
|
|
|
|
@Override
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
textFieldValueLogin = textLogin.getText();
|
|
textFieldValuePasswort = textPasswort.getText();
|
|
|
|
if(textFieldValueLogin.equals("user") && textFieldValuePasswort.equals("testpasswort")) {
|
|
System.out.println("Login erfolgreich");
|
|
JOptionPane.showMessageDialog(null, "Erfolgreich angemeldet!", "Coolio", JOptionPane.OK_OPTION);
|
|
//JOptionPane.showInternalMessageDialog(frame, "Erfolgreich angemeldet!", "Coolio", JOptionPane.INFORMATION_MESSAGE);
|
|
this.frame.setVisible(false);
|
|
this.frame.dispose();
|
|
} else {
|
|
System.out.println("Login nicht erfolgreich");
|
|
JOptionPane.showMessageDialog(null, "Falscher Nutzername oder Passwort.", "Achtung", JOptionPane.ERROR_MESSAGE);
|
|
|
|
}
|
|
}
|
|
}
|