title: making jfilechooser show image thumbnails
body: <p>I wanted to create a <code>JFileChooser</code> with thumbnail view of image files.So I subclassed FileView and in the method which creates <code>ImageIcon</code> did some scaling sothat thumbnail images are shown.</p>
  
  <p>However,the overall effect is that, the <code>filechooser</code> widget takes some time before opening a directory and showing thumbnails..In createImageIcon() below,I need to call new ImageIcon() twice-once with the image filepath and next with the resized image as constructor argument.I think this is what slows the widget .</p>
  
  <p>Is there a more efficient alternative?Any suggestions/pointers most welcome.</p>
  
  <p>thanks,
  mark</p>
  
  <pre><code>public static void main(String[] args) { 
      JFileChooser chooser=new JFileChooser();
      ThumbNailView thumbView=new ThumbNailView();
      chooser.setFileView(thumbView);
    }
  
  class ThumbNailView extends FileView{
   public Icon getIcon(File f){
    Icon icon=null;
    if(isImageFile(f.getPath())){
     icon=createImageIcon(f.getPath(),null);
    }
    return icon;
   }
   private ImageIcon createImageIcon(String path,String description) {
    if (path != null) {
     ImageIcon icon=new ImageIcon(path);
     Image img = icon.getImage() ; 
     Image newimg = img.getScaledInstance( 16, 16,  java.awt.Image.SCALE_SMOOTH ) ;
     return new ImageIcon(newimg);
    } else {
     System.err.println("Couldn't find file: " + path);
     return null;
     }
  }
  
  private boolean isImageFile(String filename){
      //return true if this is image
  }
  </code></pre>