title: Making a MouseAdapter refer to the JComponent it's being added to
body: <p>I have a multitude of  Buttons that should mostly function in the same way, but change different variables linked to the button when pressed (mainly the color). I want to slim the code down as much as possible (and not type the same thing 10 times).</p>
  
  <p>How would I go about writing this adapter so it can be used for button1, as well as button2?   </p>
  
  <pre><code>MouseAdapter customMouseAdapter = new MouseAdapter() {
              @Override
              public void mouseClicked(MouseEvent e) {
                  button1.setForeground(Color.WHITE);
  
              }
          };
  
      button1.addMouseListener(customMouseAdapter);
      button2.addMouseListener(customMouseAdapter);
  </code></pre>