Browse Source

HA10 fertig

master
fdai7303 2 years ago
parent
commit
dc20951281
  1. 31
      GameProject/src/ui/LoginWIndow.java

31
GameProject/src/ui/LoginWIndow.java

@ -6,29 +6,54 @@ 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);
JButton button = new JButton();
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) {
// TODO Auto-generated method stub
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);
}
}
}
Loading…
Cancel
Save