StringBuffer hangman
<p>In my hangman application I want to hide a word that's suppose to be guessed, with "_" and I finally found a site where someone explains on how to do that but when I fused his code with mine I seem to get errors when I run it... </p>

<p>This is the site where I found the code</p>

<p><a href="http://www.jcreator.com/forums/index.php?showtopic=7761" rel="nofollow">http://www.jcreator.com/forums/index.php?showtopic=7761</a></p>

<p>and this is how I tried to use his code</p>

<pre><code>StringBuffer original = new StringBuffer(readWord());
StringBuffer secret = new StringBuffer(hideWord()) ;
StringBuffer hidden;
</code></pre>

<hr>

<pre><code> public StringBuffer hideWord(){
    for (int i = 0; i &lt; original.length(); i++){
        hidden.append("_ ");
    }
    hidden.deleteCharAt(hidden.length()-1);
    return hidden;
}
</code></pre>

<hr>

<pre><code> public JButton getButton(final String text){
   final JButton button = new JButton(text);
    button.addActionListener(new ActionListener(){
         public void actionPerformed(ActionEvent e){
             String s = button.getText();
             int index = original.indexOf(s);
             if(index != -1){
                 hidden.deleteCharAt(index*2);
                 hidden.insert(index *2, s);
             }
             else{
                 JOptionPane.showMessageDialog(null, "There is no " + text );
                 error++;
                    if(error &gt;= 0) imageName = "hangman1.jpg";
                    if(error &gt;= 1) imageName = "hangman2.jpg";
                    if(error &gt;= 2) imageName = "hangman3.jpg";
                    if(error &gt;= 3) imageName = "hangman4.jpg";
                    if(error &gt;= 4) imageName = "hangman5.jpg";
                    if(error &gt;= 5) imageName = "hangman6.jpg";
                    if(error &gt;= 7) imageName = "hangman7.jpg"; 
             }
             }
             });
             return button;
}
</code></pre>

<p>and seem to get an problem with my JLabel when displaying the word so I changed it .toString</p>

<pre><code>JLabel word = new JLabel(secret.toString());
</code></pre>

<p>can someone please tell me wy my app doesn't want to run and if the way i fused the code is correct?</p>
