Instead of adding your mouse listener in paintComponent
, which is called any time the component needs to be repainted, you should add it in the constructor. That way your panel will only have one mouse listener.
As it stands you add a new one every time you repaint, so they'll keep building up.
So, basically:
public class HoofdMenu extends JPanel {
// ... member vars
public HoofdMenu() {
this.addMouseListener(new MouseInput());
}
@Override
public void paintComponent(Graphics g) {
// ... don't add listener in here
}