title: populating a JList from HashMap
body: <p>I am building an applet to change colors of a jPanel but i am having difficulty getting my values to show up in the JList window.
  I know some do not like NetBeans but we are required to use it.</p>
  
  <p>This is the code that i have right now</p>
  
  <p>MainWindow.java</p>
  
  <pre><code>package ColorChanger;
  
  import ColorMap.ColorMap;
  import java.awt.event.WindowAdapter;
  import java.awt.event.WindowEvent;
  import java.util.Enumeration;
  import java.util.Hashtable;
  import java.util.Vector;
  import javax.swing.DefaultListModel;
  import javax.swing.JFrame;
  import javax.swing.JList;
  
  /**
   *
   * @author 
   */
  public class MainWindow extends javax.swing.JFrame {    
  
      /**
       * Creates new form MainWindow
       */
      public MainWindow() {
          initComponents();
          pGUI();
      }
  
      /**
       * This method is called from within the constructor to initialize the form.
       * WARNING: Do NOT modify this code. The content of this method is always
       * regenerated by the Form Editor.
       */
      @SuppressWarnings("unchecked")
      // &lt;editor-fold defaultstate="collapsed" desc="Generated Code"&gt;                          
      private void initComponents() {
  
          jPanel1 = new javax.swing.JPanel();
          lbl_Title = new javax.swing.JLabel();
          lbl_instruct = new javax.swing.JLabel();
          jScrollPane1 = new javax.swing.JScrollPane();
          jl_HT = ShowList();
  
          setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  
          lbl_Title.setText("Color Changer");
  
          lbl_instruct.setText("Select A Color:");
  
          jl_HT.setModel(new DefaultListModel());
          jl_HT.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
          jScrollPane1.setViewportView(jl_HT);
  
          javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
          jPanel1.setLayout(jPanel1Layout);
          jPanel1Layout.setHorizontalGroup(
              jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(jPanel1Layout.createSequentialGroup()
                  .addContainerGap()
                  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                      .addGroup(jPanel1Layout.createSequentialGroup()
                          .addComponent(lbl_instruct, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
                          .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                          .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE))
                      .addComponent(lbl_Title))
                  .addContainerGap(168, Short.MAX_VALUE))
          );
          jPanel1Layout.setVerticalGroup(
              jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(jPanel1Layout.createSequentialGroup()
                  .addComponent(lbl_Title)
                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                      .addComponent(lbl_instruct, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                      .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
          );
  
          javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
          getContentPane().setLayout(layout);
          layout.setHorizontalGroup(
              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(layout.createSequentialGroup()
                  .addContainerGap()
                  .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                  .addContainerGap())
          );
          layout.setVerticalGroup(
              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(layout.createSequentialGroup()
                  .addContainerGap()
                  .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                  .addContainerGap(108, Short.MAX_VALUE))
          );
  
          pack();
      }// &lt;/editor-fold&gt;                        
  
      private void pGUI() {
          JFrame mainFrame = new JFrame("Select a color to change background");
          mainFrame.addWindowListener(new WindowAdapter() {
              public void windowsClosing(WindowEvent windowevent) {
                  System.exit(0);
              }
          });
  
      }
  
      /**
       * @param args the command line arguments
       */
      public static void main(String args[]) {
          /* Set the Nimbus look and feel */
          //&lt;editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "&gt;
          /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
           * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
           */
          try {
              for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                  if ("Nimbus".equals(info.getName())) {
                      javax.swing.UIManager.setLookAndFeel(info.getClassName());
                      break;
                  }
              }
          } catch (ClassNotFoundException ex) {
              java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
          } catch (InstantiationException ex) {
              java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
          } catch (IllegalAccessException ex) {
              java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
          } catch (javax.swing.UnsupportedLookAndFeelException ex) {
              java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
          }
          //&lt;/editor-fold&gt;
  
          /*
          set Hashtable from ColorMap Package.
  
           */
   /* Create and display the form */
          java.awt.EventQueue.invokeLater(() -&gt; {
              new MainWindow().setVisible(true);
          });
      }
  
      public JList ShowList() {
          JList jListO = null;
          JList jList = new JList();
          Hashtable ht = new Hashtable();
          ht.putAll(ColorMap.hColorMap);
          JList jlist = new JList(new Vector(ht.keySet()));
          DefaultListModel dlm = (DefaultListModel)jlist.getModel();
          Enumeration e = dlm.elements();
          while (e.hasMoreElements()) {
              jListO = (JList) e.nextElement();
          }
          return jListO;
      }
  
      // Variables declaration - do not modify                     
      private javax.swing.JPanel jPanel1;
      private javax.swing.JScrollPane jScrollPane1;
      public javax.swing.JList&lt;JList&gt; jl_HT;
      private javax.swing.JLabel lbl_Title;
      private javax.swing.JLabel lbl_instruct;
      // End of variables declaration                   
  
  }
  </code></pre>
  
  <p>This is the ColorMap package building the HashMap.
  ColorMap.java</p>
  
  <pre><code>    package ColorMap;
  
  import java.awt.Color;
  import java.util.HashMap;
  
  /**
   *
   * @author 
   */
  public class ColorMap {
      /*
      Creating the HashMap of Colors
      */
      public static HashMap&lt;String, Color&gt; hColorMap = new HashMap&lt;&gt;();
  /*
      Populating the HashMap with the index and colors
      */
      public ColorMap() {
          hColorMap.put("Black", Color.BLACK);
          hColorMap.put("Blue", Color.BLUE);
          hColorMap.put("Cyan", Color.CYAN);
          hColorMap.put("Dark Gray", Color.DARK_GRAY);
          hColorMap.put("Gray", Color.GRAY);
          hColorMap.put("Green", Color.GREEN);
          hColorMap.put("Light Gray", Color.LIGHT_GRAY);
          hColorMap.put("Magenta", Color.MAGENTA);
          hColorMap.put("Orange", Color.ORANGE);
          hColorMap.put("Pink", Color.PINK);
          hColorMap.put("Red", Color.RED);
          hColorMap.put("White", Color.WHITE);
          hColorMap.put("Yellow", Color.YELLOW);
      }
  
      private String getName(Color color) {
          return color.getClass().getName();
      }
  
      public HashMap&lt;String, Color&gt; getColor() {
          return hColorMap;
      }
  
  }
  </code></pre>
  
  <p>I am having an issue getting the name from the HashMap to show up in the JList</p>