title: How to add an image in a for loop in java
body: <p>This is for a hangman game</p>
  
  <pre><code>public static String letterGuessed;
  public static String[] word = {"fuzzy","chess","elephant","cheesecake","charger","laptop","relevance","funnybone"};
  public static int ran;
  public static JLabel jl = new JLabel();
  
   public void wordGenerator(){
  
  
      int max = 8;
      int wordLength;
      int counter = 0;
  
      int min = 0;
      ran = (int)(Math.random()* (max - min +1) + min);
  
      wordLength = word[ran].length();
  
      while (counter &lt;= wordLength){
  
          lblWord.setText( lblWord.getText() + "_ ");
  
          counter++;
  
      }
  
  }
  public void getLetter(){
  
      letterGuessed = txtLetterGuess.getText();
  
  
  }
  
  
  
  public void rightOrWrongGuess() {
  
      if (word[ran].contains(letterGuessed)){
  
          //lblWord.replace.
  
      } else {
  
          //PICTURE CHANGE
  
  
      }
  
      lblGuessedLetters.setText(lblGuessedLetters.getText() + "_ " + letterGuessed);
  
  }
  private void btnGuessLetterActionPerformed(java.awt.event.ActionEvent evt) {   
  
  
      getLetter();
      rightOrWrongGuess();
  
      for (int i=0;i&lt;=6;i++) {
          if (!word[ran].contains(letterGuessed)) {
              lblPicture.setIcon(new ImageIcon("C:\\Pic\\hangman" + i + ".jpg")); 
  
          }
      }
  </code></pre>
  
  <p>So I tried to use the counter to upload a different picture each time they guess the wrong letter. There is only 6 pictures, the last being the full hangman. The <code>i</code> or <code>counter</code> doesn't seem to work. </p>
  
  <p>I think that I would not get a rapid succession of pictures because they would have to click the button each time.
  Thanks.</p>