From f36500d195900bbddab59dc2bb82c2a20a357bad Mon Sep 17 00:00:00 2001 From: Lorenz Hohmann Date: Fri, 14 Jan 2022 12:05:01 +0100 Subject: [PATCH] Added mouse listener to register click on matchfield --- src/main/java/de/tims/fleetstorm/gui/GUI.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/de/tims/fleetstorm/gui/GUI.java b/src/main/java/de/tims/fleetstorm/gui/GUI.java index 5bd0a99..0a4083c 100644 --- a/src/main/java/de/tims/fleetstorm/gui/GUI.java +++ b/src/main/java/de/tims/fleetstorm/gui/GUI.java @@ -3,6 +3,8 @@ package de.tims.fleetstorm.gui; import java.awt.Color; import java.awt.Font; import java.awt.GridLayout; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; import java.util.ArrayList; import javax.swing.JFrame; @@ -170,6 +172,15 @@ public class GUI extends JPanel { field.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0))); fields.add(field); fieldWrapper.add(field); + + field.addMouseListener(new MouseAdapter() { + + public void mouseClicked(MouseEvent e) { + field.setBackground(Color.RED); + field.revalidate(); + field.repaint(); + } + }); } }