Originally Posted by
Jakesta42
As you can see in the code, the 'WinnerString' is undefined at first. It is set to the value of the button if a winning combination is met. Otherwise it stays blank. When the button is clicked (which calls the ActionPerformed method), the value of the button stays blank until the next actionPerformed.
String aString;
ActionPerformed()
{
if(condition)
{
aString = "X";
}
}
Print(aString);
1st ActionPerformed prints blank string
2nd ActionPerformed prints "X"
It's difficult to explain via the use of text :/
It seems as though the 'WinnerString' becomes X too late, and it is not processed as X until after the ActionPerformed.
Well, why don't you use mouse events like mouse pressed, mouse released etc? And i am not sure if mouse events work with applets as i didn't work too much with applets...