Browse Source

Hausi 10 fast fertig

master
Emma Nagelschmidt 2 years ago
parent
commit
512ec29a2f
  1. 3
      GameProject/src/base/GameLoop.java
  2. 8
      GameProject/src/log4j2.xml
  3. 29
      GameProject/src/ui/GameUIWithLogin.java
  4. 34
      GameProject/src/ui/LoginWIndow.java

3
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;

8
GameProject/src/log4j2.xml

@ -33,6 +33,12 @@
</Logger>
<Logger name="playground.BreakoutLevel1" level="trace">
</Logger>
</Logger>
<Logger name="ui.GameUIWithLogin" level="debug">
</Logger>
<Logger name="ui.GameUIWithLogin" level="trace">
</Logger>
</loggers>
</configuration>

29
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.");
}
}
}

34
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
}
}
Loading…
Cancel
Save