title: Java: Iterate JMenuItem from ArrayList with HashMaps
body: <p>I have a JFrame with a menubar, in which i'd like some dynamic menus, as in, depending on the size of the ArrayList with HashLists. The problem here is that i then got a dynamic amount of JMenuItems, so i need a way to get as much variables as HashLists. In this case i made the name of the variable static, but obviously that's not working on the ActionListener, since all MenuItems will have the same ActionListener.</p>
  
  <p>I'm wondering how to solve this, and how to get a menu with a dynamic amount of menuitems which all have unique actionlisteners. </p>
  
  <pre><code>private ArrayList&lt;HashMap&gt; menuLijst;
  </code></pre>
  
  <p>.</p>
  
  <pre><code>    for (HashMap h : menuLijst) {
          String vraag = (String) h.get("vraag");
          JMenuItem qMenu = new JMenuItem(vraag);
          informatie.add(qMenu);
          qMenu.addActionListener(this);
      }
  </code></pre>
  
  <p>Thanks in advance.</p>