From 512ec29a2fd3fef81fce68e0b3c2ba623e84a6a3 Mon Sep 17 00:00:00 2001 From: Emma Nagelschmidt Date: Thu, 30 Jun 2022 09:37:07 +0200 Subject: [PATCH] Hausi 10 fast fertig --- GameProject/src/base/GameLoop.java | 3 ++- GameProject/src/log4j2.xml | 8 +++++- GameProject/src/ui/GameUIWithLogin.java | 29 +++++++++++++++++++++ GameProject/src/ui/LoginWIndow.java | 34 +++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 GameProject/src/ui/GameUIWithLogin.java create mode 100644 GameProject/src/ui/LoginWIndow.java diff --git a/GameProject/src/base/GameLoop.java b/GameProject/src/base/GameLoop.java index f98bd42..a5011aa 100644 --- a/GameProject/src/base/GameLoop.java +++ b/GameProject/src/base/GameLoop.java @@ -10,6 +10,7 @@ import gameobjects.GameObject; import playground.Level1; import playground.Playground; import ui.GameUI; +import ui.GameUIWithLogin; /** @@ -86,7 +87,7 @@ public class GameLoop { public void runGame(String[] args) throws IOException { logger.info("GUI starts"); - GameUI gameUI = new GameUI(SIZEX, SIZEY); // probably change to your new GUI class + GameUIWithLogin gameUI = new GameUIWithLogin(SIZEX, SIZEY); // probably change to your new GUI class double gameTime = -1; Playground currentPlayground = null; diff --git a/GameProject/src/log4j2.xml b/GameProject/src/log4j2.xml index 72d04fb..c62d79c 100644 --- a/GameProject/src/log4j2.xml +++ b/GameProject/src/log4j2.xml @@ -33,6 +33,12 @@ - + + + + + + + \ No newline at end of file diff --git a/GameProject/src/ui/GameUIWithLogin.java b/GameProject/src/ui/GameUIWithLogin.java new file mode 100644 index 0000000..896a70a --- /dev/null +++ b/GameProject/src/ui/GameUIWithLogin.java @@ -0,0 +1,29 @@ +package ui; +import java.awt.event.ActionEvent; +import javax.swing.JMenu; +import javax.swing.JMenuItem; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + + +public class GameUIWithLogin extends GameUI { + private static Logger logger = LogManager.getLogger(GameUIWithLogin.class); + JMenuItem login = new JMenuItem("login"); + + public GameUIWithLogin(int sizeX, int sizeY) { + super(sizeX, sizeY); + logger.info("Konstruktor wurde aufgerufen."); + + login.addActionListener(this); + this.gameMenu.insert(login, 0); + } + + public void actionPerformed(ActionEvent ae) { + super.actionPerformed(ae); + if (ae.getSource() == this.login) { + new LoginWIndow(); + logger.info("Wird aufgerufen."); + } + } +} diff --git a/GameProject/src/ui/LoginWIndow.java b/GameProject/src/ui/LoginWIndow.java new file mode 100644 index 0000000..1d15522 --- /dev/null +++ b/GameProject/src/ui/LoginWIndow.java @@ -0,0 +1,34 @@ +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.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); + JLabel labelPasswort = new JLabel("passwort"); + JTextField textPasswort = new JTextField(null, 20); + JButton button = new JButton(); + + public LoginWIndow() { + this.frame.setSize(250, 300); + this.frame.setContentPane(panel); + this.button.addActionListener(this); + this.frame.setVisible(true); + + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + } +}