title: How to create JList with icon and text?
body: <p>I have this code want to make <code>JList</code> talk text and icon what must to do.<br>
  Some persons advice me to make list of label and in table put text an icon is it Possible? How?  </p>
  
  <p>Search on <code>/////////////////</code> for embedded comment.</p>
  
  <pre><code>import javax.swing.JPanel;
  import javax.swing.JButton;
  import javax.swing.JLabel;
  import java.awt.datatransfer.DataFlavor;
  import java.awt.datatransfer.Transferable;
  import java.awt.datatransfer.UnsupportedFlavorException;
  import java.awt.dnd.DropTarget;
  import java.awt.dnd.DropTargetDragEvent;
  import java.awt.dnd.DropTargetDropEvent;
  import java.awt.dnd.DropTargetEvent;
  import java.awt.dnd.DropTargetListener;
  import java.io.File;
  import java.io.IOException;
  import java.util.List;
  import javax.swing.DefaultListModel;
  import javax.swing.Icon;
  import javax.swing.JList;
  import javax.swing.JScrollPane;
  import javax.swing.filechooser.FileSystemView;
  
  public class pan extends JPanel implements DropTargetListener {
  
  private DefaultListModel listModel = new DefaultListModel();
  private DropTarget dropTarget;
  private JLabel jLabel1;
  private JScrollPane jScrollPane1;
  private JList list;
  
  /**
   * Create the panel.
   */
  public pan() {
      setLayout(null);        
      list = new JList();
      dropTarget = new DropTarget(list, this);
      list.setModel(listModel);
      list.setDragEnabled(true);
      //list.setTransferHandler(new FileTransferHandler());
      jScrollPane1 = new JScrollPane();
  
      jScrollPane1.setViewportView(list);
      jScrollPane1.setBounds(10, 150, 635, 330);
      add(jScrollPane1);
  
  }
  public void dragEnter(DropTargetDragEvent arg0) {
      // nothing
  }
  
  public void dragOver(DropTargetDragEvent arg0) {
      // nothing
  }
  
  public void dropActionChanged(DropTargetDragEvent arg0) {
      // nothing
  }
  
  public void dragExit(DropTargetEvent arg0) {
      // nothing
  }
  
  public void drop(DropTargetDropEvent evt) {
      int action = evt.getDropAction();
      evt.acceptDrop(action);
      try {
          Transferable data = evt.getTransferable();
          if (data.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
                List&lt;File&gt; files = (List&lt;File&gt;) data.getTransferDat(DataFlavor.javaFileListFlavor);
              for (File file : files) {
  
      Icon icon=FileSystemView.getFileSystemView().getSystemIcon(file);
  /////////////////listModel.addElement(filepath+icon);///////////////////////want code do this
  
              }
          }
      } catch (UnsupportedFlavorException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      } finally {
          evt.dropComplete(true);
      }
   }
  
  }
  </code></pre>
  
  <p>After solve this problem i will add action to each element if doubel click on it will open desktop<br>
  to path stored in list.</p>