<HTML>
<BODY>
<APPLET CODE= MyHangman.class WIDTH=1000 HEIGHT=1000>
</APPLET>
</HTML>

I need to know what to do next below is my java file and I am confused with how to check the words i have in the array and the letters guessed in the word....anything would be useful thanks......and do you guys think that an ActionListener would be the easiest to see which button is clicked

Keep in mind that swing is event-driven.

In order to check a word for a character, you should create a method that iterates through each character of that word.

public boolean charIsInWord(String word, char arg)
{
char[] charWord = word.toCharArray();

//iterate through the values of the char array and compare them to the char argument

//return true if a match was found, or return false if no match was found
}

If this method returns false when someone clicks a button then something needs to happen. Like I said, swing is event driven so your buttons need their ActionListener interfaces set to non-null so their ActionListener.actionPerformed(ActionEvent e) methods can fire.

Basically, you need to implement the ActionListener interface, one way or another (either through an interface implementation directly to your class, to an interface object, in an enum, in some other class that supports buttons... any of those ways work!) and setActionCommand(String arg) for each button.

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.