Hi everyone, Im new to site and new to Java - have an assignment in Hangman - to date I have created the Hangman class and coded the tester so its working with 1 word! I have also coded the hangman component which is currently static and displayed on opening the component viewer. My problem is how do I join up the class and the component to run the GUI game.

e.g. code to replace the secretWord with dashes is

//change string to char and fill with dashes 
           public void setDashWord()    
{   
    dashWord = new char[secretWord.length()];
    for (int i=0; i< secretWord.length(); i++)
    {
        dashWord[i]='-';
    }


}   

how do i link this to the text field so it prints out the dashes. I am confusing myself reading text books and no further forward. Thanks for any help

Are you using a JTextField? Then it would be textField.setText(someString); to set the text. Other than that, you haven't given nearly enough code for anyone to be of assistance..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.