title: Determine clicked JPanel component in the MouseListener. Event handling
body: <p>I have a class whitch extends JPanel:</p>
  
  <pre><code>public class ButtonPanel extends JPanel {
  
      private label;
  
      public ButtonPanel() {
          label=new JLabel("waiting for click");
          add(label);
      }
  
      public void setButtonText() {
          label.setText("just clicked");
      }
  
  }
  </code></pre>
  
  <p>I have several instances of that class which is added to JFrame. I want to create one instanse of MouseAdapter class and then add them as a mouse listener to all of the ButtonPanel components on my JFrame. I meen:</p>
  
  <pre><code>ButtonPanel butt1 = new ButtonPanel();
  ButtonPanel butt2 = new ButtonPanel();
  ButtonPanel butt3 = new ButtonPanel();
  //... here goes code which add ButtonPanels to JFrame
  
  MouseAdapterMod mam = new MouseAdapterMod();
  butt1.addMouseListener(mam);
  butt2.addMouseListener(mam);
  butt3.addMouseListener(mam);
  </code></pre>
  
  <p>The MouseAdapterMod class I want to be separate from the other and locate in it's own package. It should looks like this:</p>
  
  <pre><code>public class MouseAdapterMod extends MouseAdapter {
  
      public void mouseClicked(MouseEvent e) {
          //here goes the code of calling setButtonText method of ButtonPanel component on which the event had occurred
      }
  }
  </code></pre>
  
  <p>So the problem is that I don't know how to implement mouseClicked method to make it determine which of ButtonPanel generate the event and call the corresponding to that component setButtonText() method. Is anyone know how to do that?</p>
  
  <p>I know that I can achieve this by including event handling functionality in the ButtonPanel class, but thats not appropriate way for me, cuz I want to keep the class structure as I described above and have only one instance of MouseAdapterMod class for handling all of the ButtonPanels.</p>