title: Have something loaded only when JList item is visibile
body: <p>i'm implementing a Jlist populated with a lot of elements. Each element corresponds to a image so i'd like to show a resized preview of them inside each row of the list. I've implemented a custom <strong>ImageCellRenderer</strong> extending the Jlabel and on <strong>getListCellRendererComponent</strong> i create the thumbnail if there'snt any for that element. Each row corresponds to a <strong>Page</strong> class where i store the path of the image and the icon applied to the JLabel. Each <strong>Page</strong> object is put inside a <strong>DefaultListModel</strong> to populate the JList.
  The render code is something like this:</p>
  
  <pre><code>        public Component getListCellRendererComponent(
              JList list,
              Object value,
              int index,
              boolean isSelected,
              boolean cellHasFocus)
      {
          Page page = (Page) value;
  
          if (page.getImgIcon() == null)
          {
              System.out.println(String.format("Creating thumbnail of %s", page.getImgFilename()));
              ImageIcon icon = new ImageIcon(page.getImgFilename());
  
              int thumb_width = icon.getIconWidth() &gt; icon.getIconHeight() ? 128 : ((icon.getIconWidth() * 128) / icon.getIconHeight());
              int thumb_height = icon.getIconHeight() &gt; icon.getIconWidth() ? 128 : ((icon.getIconHeight() * 128) / icon.getIconWidth());
              icon.setImage(getScaledImage(icon.getImage(), thumb_width, thumb_height));
  
              page.setImgIcon(icon);
          }
  
          setIcon(page.getImgIcon());
  
      }
  </code></pre>
  
  <p>I was thinking that only a certain item is visibile in the List the cell renderer is called but i'm seeing that all the thumnails are created when i add the Page object to the list model. I've tried to load the items and after set the model in the JList or set the model first and after starting appending the items but the results are the same.
  Is there any way to load the data only when necessary or do i need to create a custom control like a JScrollPanel with stacked items inside where i check myself the visibility of each elements?</p>
  
  <p>Thanks</p>