title: Adding element to jList in Netbeans 8.2
body: <p>Using "test" rather than my string results to make less specific. Have checked other questions with this problem and have attempted but cannot find answer that works.</p>
  
  <p>Trying to firstly print just "test" into my jList FriendsList which has been sent up through Netbeans. The model is default and I can't see anything wrong with the way I've set it up. The file is reading correctly as the System.out.</p>
  
  <p>Java:</p>
  
  <pre><code>    DefaultListModel  listOfFriends;
      listOfFriends = new DefaultListModel();
      friendsList = new JList(listOfFriends);
  
      String[] result = line.split(","); // line is previously init.
  
      for (int i = 0; i &lt; result.length; i++)
           listOfFriends.addElement("test"); // THIS DOES NOT WORK
           System.out.println(result); // THIS WORKS
      }
  </code></pre>
  
  <p>The JList is added to the frame at the end of the file as Netbeans <strong>automatically</strong> does and then you cannot change it. </p>
  
  <p>Java end of file (variables declaration which cannot be edited):</p>
  
  <pre><code>public javax.swing.JList&lt;String&gt; friendsList;
  </code></pre>