title: How to add an action Listener in DefaultListModel and not in JList
body: <p>I have the following code and i add elements to a <code>JList</code>.</p>
  
  <pre><code>DefaultListModel listModel = new DefaultListModel();
  listModel.addElement("element1");
  listModel.addElement("element2");
  listModel.addElement("element3");
  list = new JList(listModel);
  list.addListSelectionListener(this);
  </code></pre>
  
  <p>In <strong>another method</strong> of my code </p>
  
  <ul>
  <li>I remove all the elements of listModel(<code>DefaultListModel</code>) and </li>
  <li><p>I add the elements of a <code>SortedSet</code>: (<em><code>listModel</code> is a <code>public static</code> variable)</em> </p>
  
  <pre><code>listModel.removeAllElements();
  SortedSet&lt;String&gt; keys = new TreeSet&lt;String&gt;(myHashMap.keySet());
      Iterator&lt;String&gt; it = keys.iterator();
      while (it.hasNext()) {
          String key = it.next();
          listModel.addElement(key);
          //How can i add an addActionListener to every 'key element'
          //since the JList list variable is not global ??
      }
  </code></pre></li>
  </ul>
  
  <p>Since <strong>'list'</strong> is <strong>not</strong> a public static variable, how can I add an Action Listener
  to each one of the list Items in the listModel?</p>
  
  <p>I tried to use an <code>addListDataListener</code>, but I don't think that is use for the purpose that I need.</p>