title: Hangman game trouble with GUI
body: <p>Im new in Java socket and i try to develop a small game through socket, everything is ok on server but in client , i got trouble when i create a list of JLabel to show a letter "_" for each letter of word </p>
  
  <p>Ok i show my code you will see what trouble i got.</p>
  
  <p>my Snippett code like this:</p>
  
  <pre><code>List&lt;JLabel&gt;labels;
  
   private void getWordLabels(String word){
          char[] chars  = word.toCharArray();
          System.out.println(chars);
          int gapBetweenLetter = 300/chars.length;
          labels = new ArrayList&lt;JLabel&gt;();
  
          for(int i =0; i&lt; chars.length ;i++){
  
             // JLabel l = new JLabel("_");
              labels.add(new JLabel());
              labels.get(i).setText("_");
              //this.add(l);
              //l.setBounds(10, 10, 10, 10);
              //l.show();
              this.removeAll();
              this.revalidate();
              this.repaint();
              labels.get(i).setBounds((i*gapBetweenLetter) + 10, 100, 50, 50);
  
              this.add(labels.get(i));
  
              labels.get(i).show();
               initComponents();
  
          /* labels.add(new JLabel("_"));
          this.add(labels.get(i));
          //labels[i].setText("_");
          System.out.println(labels.get(i));
          * */
  
  
      }
  }
      }
  </code></pre>
  
  <p>but i got null pointer exception, i don't know why?</p>
  
  <p>Someone can help me or show what wrong in my code.</p>
  
  <p>Thank you!</p>