title: jButton responds only to second click (Netbeans 6.9.1, Java)
body: <p>I have an annoying problem, and I don't seem to understand where in comes from.  I have an application and a simple UI for it. The problem is that when I run the program buttons respond only to the second click. After they do what they have to do, buttons respond to the first click. I really don't know what is the source of the problem.  Here is some source code for binding jButton and actionlistener:</p>
  
  <pre><code>private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
      // TODO add your handling code here:
      jButton1.addActionListener(new SolutionListener());
  }
  </code></pre>
  
  <p>And here is actionlistener itself (if it helps):</p>
  
  <pre><code>private class ListListener implements ActionListener {
      public void actionPerformed(ActionEvent e) {
          jTextArea1.setText(null);
          if (jTextField2.getText().equals("")) {
              jTextArea1.append("Input a value");
          }
          else {
              for (int i = 2; i &lt;= Integer.valueOf(jTextField2.getText().trim()); i++) {
                  if(isSquare(i) == true) {
                      continue;
                  }
                  else {
                      PE pe = new PE(i);
                      answer = pe.solve();
                      jTextArea1.append(i + "\t");
                      jTextArea1.append(answer[0].toString() + " ");
                      jTextArea1.append(answer[1].toString() + "\n");
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>I would really appreciate any help, thanks in advance!</p>