title: String index out of range on button pressed
body: <p>Having problems with a little hangman game I'm making. </p>
  
  <pre><code>private void btnTActionPerformed(java.awt.event.ActionEvent evt) 
  {                                     
      btnT.setEnabled(false);          
      if(word.charAt(0)=='t'){
          lblSpace1.setText("T");
      }
      if(word.charAt(1)=='t'){
          lblSpace2.setText("T");
      }
      if(word.charAt(2)=='t'){
          lblSpace3.setText("T");
      }        
      if(word.charAt(3)=='t'){
          lblSpace4.setText("T");
      }        
      if(word.charAt(4)=='t'){
          lblSpace5.setText("T");
      }        
      if(word.charAt(5)=='t'){
          lblSpace6.setText("T");
      }        
      if(word.charAt(6)=='t'){
          lblSpace7.setText("T");
      }        
      if(word.charAt(7)=='t'){
          lblSpace8.setText("T");
      }        
      if(word.charAt(8)=='t'){
          lblSpace9.setText("T");
      }        
      if(word.charAt(9)=='t'){
          lblSpace10.setText("T");
      }
      if(!word.contains("t")){
          guessesLeft--;
          lblGuessesleft.setText("Number: "+guessesLeft+"");            
      }
  }
  </code></pre>
  
  <p>The code checks if the letter <code>t</code> is in each space of the word. However, some words aren't 10 characters long, so the error "String index out of range" is printed.</p>
  
  <p>Is there a way to only check the the letters that are in <code>word</code>?</p>