title: Java GUI adding buttons with a for loop
body: <p>Hi i am making a lotto gui where the user picks 4 numbers from a selection of 28. The way i am currently doing it is as follows</p>
  
  <pre><code>private void no1InputButtonActionPerformed(java.awt.event.ActionEvent evt) {                                               
      numberSelectionList.add("1");
  }                                              
  
  private void no2InputButtonActionPerformed(java.awt.event.ActionEvent evt) {                                               
       chosenNumDisplayLabel.setText(chosenNumDisplayLabel.getText()+" 2");
  }                                              
  
  private void no3InputButtonActionPerformed(java.awt.event.ActionEvent evt) {                                               
       chosenNumDisplayLabel.setText(chosenNumDisplayLabel.getText()+" 3");
  }        
  </code></pre>
  
  <p>etc up through the 28 numbers. </p>
  
  <ul>
  <li>Is there a way to add the actions to each button through a for loop
  as this seems more logical?</li>
  <li>Also is there a way to add each number picked into an array?</li>
  </ul>