title: Java - updating textFields from JList
body: <p>I am making an address book GUI with Java and I have a <code>JList</code> that displays all the names of the people in my <code>ArrayList</code> (this is populated by the <code>updateinfo</code> method mentioned below). I want it so when I click an item on the <code>JList</code>, the <code>TextField</code>s are then updated with that persons details. Before I have only used buttons and therefore <code>actionListeners</code>. I think I understand that a <code>JList</code> must use <code>ListSelectionListener</code> but I cannot seem to implement this. I have added a snippet of my code below. Can somebody please help?? For continuity with my <code>actionlisteners</code> I would like to have it as an inner class but this is not vital</p>
  
  <pre><code>JList jl;
  DefaultListModel list;
  
  list = new DefaultListModel();
  this.jl = new JList(this.list);
  //add ListSelectionListener????
  updateList();
  this.add(this.jl, layout);
  </code></pre>