myButton.setEnabled(false);
will this line disable a button from bieng played twice in tic tac toe game
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
myButton.setEnabled(false);
will this line disable a button from bieng played twice in tic tac toe game
The question is out of context.
What you've shown will disable the button from being mouse selectable and firing selected action events, but it won't prevent the underlying program logic from choosing that position as a move in the game. There must be a check in your "select a move" logic that ensures the selected square is available. Last I saw, you didn't have that check. The user and the computer players could select the same square over and over again.
njabulo ngcobo (September 16th, 2013)
ive fixed that one last question
JOptionPane.showInputDialog(" welcome");
this statement it displays welcome to the user ryt, now it also allows user to input ,idont want that ,i want it to oly displays welcom and an okay botton ,how can i modify
This tutorial will describe the various options available and how to program them.
Like Greg said, the command you mentioned will disable the button, making it unclickable and unable to fire action events. However, any kind of code invoked by the event handler can still be executed if there's different logic that does the same thing. If you want to be thorough, and both disable the button and the code it invokes, you would want to close that code in some sort of if statement. The condition of the if statement would just be some boolean variable you set up, and you would set it to true or false depending on whether you want the code inside to execute.