From cad46f5a93a3d896224699e894cf0d7240ee5ad8 Mon Sep 17 00:00:00 2001 From: fdai7382 Date: Wed, 25 Jan 2023 10:30:28 +0100 Subject: [PATCH] =?UTF-8?q?refactoring:[MouseGame=20Class]:=20Auslagern=20?= =?UTF-8?q?der=20Zur=C3=BCcksetzen-Methode.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../JavaGamelauncher/MouseGame.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) 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