title: How to I make a GUI list out of an array of objects?
body: <p>I have an array of Objects. These objects are simple, just two Strings. I have a toString() method that just returns one of those strings.</p>
  
  <p>I need to take that array of objects and make it into a visible GUI list so that the user can pick one of them. </p>
  
  <p>In main I take a long string and send it to a method that parses it and returns an array of my objects. Then I make a new JList, add it, and make it visible:</p>
  
  <pre><code>JList list = new JList(objects);
  list.setVisible(true);
  add(list);
  </code></pre>
  
  <p>However, nothing appears. I already have a GUI present on the screen at this point. In fact, the class that the above code is contained in extends JPanel. I'm not sure why I'm not seeing anything, so I figure that I'm doing something wrong.</p>
  
  <p>EDIT*<em>*</em></p>
  
  <p>Okay, so my problem was that I wasn't setting a model. However, I'm still not getting any results after setting a model. Heres the code im using:</p>
  
  <pre><code>            ScratchItem[] items = listPlaylists(line2);
  
              DefaultListModel newListModel = new DefaultListModel();
              for(ScratchItem item : items) {
                  newListModel.addElement(item);
              }
  
              JList list = new JList();
              list.setModel(newListModel);
              list.setVisible(true);
              add(list, BorderLayout.SOUTH);
              invalidate();
  </code></pre>