Browse Source

[MouseGame Class]:Hinzufügen der Mauszurücksetzen-Funktion der Nordwand.

remotes/origin/MouseGame
fdai7382 2 years ago
parent
commit
dcffb999d0
  1. 9
      JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/GamelauncherMain.java
  2. 14
      JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java

9
JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/GamelauncherMain.java

@ -1,6 +1,7 @@
package de.hs_fulda.gruppenprojekt.JavaGamelauncher; package de.hs_fulda.gruppenprojekt.JavaGamelauncher;
import java.awt.AWTException;
import java.awt.Color; import java.awt.Color;
import java.awt.EventQueue; import java.awt.EventQueue;
import java.awt.Font; import java.awt.Font;
@ -120,7 +121,13 @@ public class GamelauncherMain extends JFrame {//class
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
MouseGame frameMouse = new MouseGame();
MouseGame frameMouse = null;
try {
frameMouse = new MouseGame();
} catch (AWTException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
frameMouse.setVisible(true); frameMouse.setVisible(true);
} }
}); });

14
JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java

@ -1,8 +1,10 @@
package de.hs_fulda.gruppenprojekt.JavaGamelauncher; package de.hs_fulda.gruppenprojekt.JavaGamelauncher;
import java.awt.AWTException;
import java.awt.Color; import java.awt.Color;
import java.awt.EventQueue; import java.awt.EventQueue;
import java.awt.Font; import java.awt.Font;
import java.awt.Robot;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JLabel; import javax.swing.JLabel;
@ -10,11 +12,15 @@ import javax.swing.JPanel;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder; import javax.swing.border.LineBorder;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
public class MouseGame extends JFrame { public class MouseGame extends JFrame {
private JPanel contentPane; private JPanel contentPane;
Robot robot = new Robot();
/** /**
* Launch the application. * Launch the application.
@ -34,7 +40,7 @@ public class MouseGame extends JFrame {
}//end main }//end main
public MouseGame() {
public MouseGame() throws AWTException {
//Fensterrahmen Haupt Layout //Fensterrahmen Haupt Layout
setTitle("Maze Game"); setTitle("Maze Game");
@ -71,6 +77,12 @@ public class MouseGame extends JFrame {
panel.setLayout(null); panel.setLayout(null);
JPanel nordWand = new JPanel(); JPanel nordWand = new JPanel();
nordWand.addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
robot.mouseMove(200, 170);
}
});
nordWand.setBackground(new Color(0, 0, 0)); nordWand.setBackground(new Color(0, 0, 0));
nordWand.setBounds(0, 0, 696, 10); nordWand.setBounds(0, 0, 696, 10);
panel.add(nordWand); panel.add(nordWand);

Loading…
Cancel
Save