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 b325f43..7dc2b5f 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 @@ -77,12 +77,7 @@ 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); - } - }); + extracted(nordWand); nordWand.setBackground(new Color(0, 0, 0)); nordWand.setBounds(0, 0, 696, 10); panel.add(nordWand); @@ -104,16 +99,21 @@ public class MouseGame extends JFrame { JPanel panel_1 = new JPanel(); panel_1.setBounds(801, 518, 83, 62); - panel_1.addMouseListener(new MouseAdapter() { - @Override - public void mouseEntered(MouseEvent e) { - robot.mouseMove(200, 170); - } - }); + extracted(panel_1); contentPane.add(panel_1); }//end standardkonstruktor + + + private void extracted(JPanel panel) { + panel.addMouseListener(new MouseAdapter() { + @Override + public void mouseEntered(MouseEvent e) { + robot.mouseMove(200, 170); + } + }); + } }//end class