title: Using the JList .setModel() method with a class as an argument
body: <p>My ultimate goal is to have a JList which refreshes its content at runtime, and I have found a solution that works from this post <a href="https://stackoverflow.com/questions/3268383/java-refreshing-an-array-into-jlist">here on SO</a>, however I am curious why my original idea did not.</p>
  
  <p>As of now, I have something like this setup and it works:</p>
  
  <pre><code>DefaultListModel default = new DefaultListModel();
  
  for(int i = 0; i &lt; array.size() ; ++i){
     test.addElement(array.get(i));
  }
  list.setModel(default);
  </code></pre>
  
  <p>Below was my original plan. I wanted to have a class which implemented ListModel be passed as an argument, hoping it would refresh the JList.</p>
  
  <pre><code>SomeClass test = new SomeClass(); //Implements ListModel
  list.setModel(test);
  </code></pre>
  
  <p>or</p>
  
  <pre><code>SomeClass test = new SomeClass(); //Implements ListModel
  list = new JList(test);
  </code></pre>
  
  <p>Neither of these work, which confuses me. Could these last two methods work some how, the code is so much cleaner.</p>
  
  <p>Thanks.</p>