diff --git a/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/GamelauncherMain.java b/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/GamelauncherMain.java index f5aaf5c..f1de6cf 100644 --- a/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/GamelauncherMain.java +++ b/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/GamelauncherMain.java @@ -1,6 +1,7 @@ package de.hs_fulda.gruppenprojekt.JavaGamelauncher; +import java.awt.AWTException; import java.awt.Color; import java.awt.EventQueue; import java.awt.Font; @@ -120,7 +121,13 @@ public class GamelauncherMain extends JFrame {//class public void actionPerformed(ActionEvent e) { // 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); } }); diff --git a/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java b/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java index 48b9533..5fbda60 100644 --- a/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java +++ b/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java @@ -1,8 +1,10 @@ package de.hs_fulda.gruppenprojekt.JavaGamelauncher; +import java.awt.AWTException; import java.awt.Color; import java.awt.EventQueue; import java.awt.Font; +import java.awt.Robot; import javax.swing.JFrame; import javax.swing.JLabel; @@ -10,11 +12,15 @@ import javax.swing.JPanel; import javax.swing.SwingConstants; import javax.swing.border.EmptyBorder; import javax.swing.border.LineBorder; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; public class MouseGame extends JFrame { - private JPanel contentPane; + private JPanel contentPane; + Robot robot = new Robot(); + /** * Launch the application. @@ -30,17 +36,17 @@ public class MouseGame extends JFrame { } } }); - + }//end main - public MouseGame() { + public MouseGame() throws AWTException { //Fensterrahmen Haupt Layout setTitle("Maze Game"); setBounds(100, 100, 900, 650); - + contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); @@ -71,6 +77,12 @@ public class MouseGame extends JFrame { panel.setLayout(null); 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.setBounds(0, 0, 696, 10); panel.add(nordWand);