title: JList's ListCellRenderer not printing the proper index of the DefaultListModel
body: <p>I have a <code>JScrollPane</code> panel with <code>JList mediaList</code>. Content of the list is maintained by <code>DefaultListModel</code>. I get new list model after making a query through JDBC (Sqlite 3)</p>
  
  <p>I'm facing an issue where scroll pane doesn't paint new index of the model when size of the newly generated model is greater than the size of the earlier fetched model.</p>
  
  <p>//Code snippet</p>
  
  <pre><code>label.addMouseListener (new MouseAdapter() {
      DefaultListModel&lt;HashMap&lt;String,String&gt;&gt; mediaModel=new DefaultListModel&lt;&gt;();
      mediaModel=mProvider.getNextMenu(paramsCid); // new DefaultListModel
  
      medialist = new JList(mediaModel);
      medialist.setOpaque(false);         
      medialist.setCellRenderer(new MediaCellRenderer());
  
      panel = new JScrollPane(medialist);
      panel.setPreferredSize(new Dimension(300,300));
      pane1.setOpaque(true);
  });
  
  class MediaCellRenderer implements ListCellRenderer {
      public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
          System.out.println("index: "+index);
          JLabel menuTextLabel = new JLabel(mediaModel.get(index).get("title"));
          return menuTextLabel;
      }
  }
  </code></pre>
  
  <p>Have observed that <code>MediaCellRenderer</code> prints below index when length of <code>mediaModel</code> is 2</p>
  
  <pre><code>index: 0  
  index: 1
  </code></pre>
  
  <p>But, it prints below index when  length of mediaModel is 3</p>
  
  <pre><code>index: 0  
  index: 1  
  index: 0 // it prints 0 instead of 2
  </code></pre>
  
  <p>Can anyone help in figuring out this issue?</p>