title: How to dynamically add items to a JList?
body: <p>I'm having trouble adding items to a <code>JList</code> called <code>lstContacts</code> whenever a button is pressed.</p>
  
  <p>When I press my new contact button, a line should be added to <code>lstContacts</code> but when I press the button nothing happens.</p>
  
  <p>Here is my action listener for the new contact button:</p>
  
  <pre><code>newContactButton.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
              Contacts contacts = new Contacts();
  
              contacts.createContact();
          }
      });
  </code></pre>
  
  <p>Here is my <code>createContact</code> method in the contacts class:</p>
  
  <pre><code>ArrayList&lt;String&gt; contactsList = new ArrayList&lt;String&gt;();
  public void createContact() {
      ContactsDB database = new ContactsDB();
      System.out.println("new contact");
      contactsList.add("New Contact");
      listModel.addElement("New Contact");
  }
  </code></pre>
  
  <p>And lastly here is my <code>createCustomUIComponent()</code> method:</p>
  
  <pre><code>private void createUIComponents() {
      // TODO: place custom component creation code here
      listModel = new DefaultListModel();
      lstContacts = new JList&lt;String&gt;(listModel);
  }
  </code></pre>
  
  <p>Why aren't the new contacts getting added to my <code>JList</code>?</p>