title: jButton HashMap count click
body: <p>Using the code from this <a href="https://stackoverflow.com/questions/37291618/get-count-number-of-hashmap-value">link</a> loading text file contents to GUI:</p>
  
  <pre><code>Map&lt;String, ArrayList&lt;String&gt;&gt; sections = new HashMap&lt;&gt;();
  String s = "", lastKey="";
  try (BufferedReader br = new BufferedReader(new FileReader("input.txt"))) {
      while ((s = br.readLine()) != null) {
          String k = s.substring(0, 10).trim();
          String v = s.substring(10, s.length() - 50).trim();
          if (k.equals(""))
              k = lastKey;
  
          ArrayList&lt;String&gt; authors = null;
          if(sections.containsKey(k))
          {
              authors = sections.get(k);
          }
          else
          {
              authors = new ArrayList&lt;String&gt;();
              sections.put(k, authors);
          }
          authors.add(v);
          lastKey = k;
      }
  } catch (IOException e) {
  }
  </code></pre>
  
  <p>With the help of @Michael Markidis counting the <code>HashMap</code> items using this code:</p>
  
  <pre><code>// to get the number of authors
  int numOfAuthors = sections.get("AUTHOR").size();
  </code></pre>
  
  <p>Now I w'd like to use <code>numOfAuthors</code> as a parameter of <code>jButton1</code>, for example:</p>
  
  <pre><code>jButton1.doClick(numOfAuthors);
  </code></pre>
  
  <p>Actually general structure of GUI: I have <code>jPanel1</code> with <code>jTextField1</code> and <code>jButton1</code>. <code>jButton1</code> adding dynamic <code>tf</code> to <code>jPanel2</code>.</p>
  
  <pre><code>private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
      SubPanel sub = new SubPanel();
      jPanel2.add(sub);
      jPanel2.revalidate();  
  }
  </code></pre>
  
  <p>The number of items in <code>HashMap</code> is <em><code>12</code></em>, so I wo'd like to use this number as a parameter of <code>jButton1</code> and click <em><code>12</code></em> times and add additional <em><code>12</code></em> <code>sub</code>'s.</p>
  
  <pre><code>    System.out.println(numOfAuthors);
      Output: 12
  </code></pre>
  
  <p>But for this moment <code>jButton1</code> adds just <em><code>1</code></em> <code>sub</code>.</p>
  
  <p>I can't understand why it doesn't work properly.</p>