title: How do I access the source of an ActionEvent when the ActionListener is located in a different class?
body: <p>I can't get my head round this one. I've tried to adhere to the MVC pattern for the first time and now have difficulties accessing the source of an ActionEvent because the ActionListener is located in a different class. But let the code do the talking...</p>
  
  <p>In the "view":</p>
  
  <pre><code>// ControlForms.java
  
  ...
  
  private JPanel createSearchPanel() throws SQLException {
  
  ...
  
  comboBoxCode = new JComboBox(); // Field comboBoxCode -&gt; JComboBox()
      SwingUtilities.invokeLater(new Runnable() {  
          public void run() {  
              AutoCompleteSupport&lt;Object&gt; support = AutoCompleteSupport.install(
  comboBoxCode, GlazedLists.eventListOf(jnlCodeArray));
          }  
      });  // Auto-Complete comboBox from GlazedLists
  
  ...
  
  public void setComboListener(ComboListener comboListener) {
      comboBoxCode.addActionListener(comboListener);
  }
  
  ...
  
  }
  </code></pre>
  
  <p>Then, in what I term the controller, I have two different classes:</p>
  
  <pre><code>// Controller.java
  
      public MyController() throws SQLException {
  ...
      addListeners();
  }
  
  ...
  
      private void addListeners(){
      View view = getView();
      getView().getControlForm().setComboListener(new ComboListener());
  
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>public class ComboListener implements ActionListener {
  public void actionPerformed(ActionEvent e) {
      System.out.println("ComboBox listened to! e = " + e.toString());
  }
  }
  </code></pre>
  
  <p>Now, <code>e</code> obviously doesn't give the name of the variable (which at the moment I wish it would), so I cannot <code>if</code> test for <code>e.getSource()</code>. </p>
  
  <p>My question is thus: is there <em>either</em> <strong>a)</strong> a way to query (via <code>if</code> for example) the source of e, or <strong>b)</strong> a less complicated way to get to the variable name?</p>
  
  <p>Many, many thanks in advance for your insights and tips!</p>