Im making tic tac toe app, after first click on the button it get either "O" or "X" text and I want to avoid second click, like I want to make it immune to second click
if (!pola[i].getText().isEmpty()) {
pola[i].setEnabled(true);
}
so far I got this,
CodePudding user response:
make a boolean clicked
set it to true when the button is clicked, then in the action listener method check if !clicked
before you execute the code, or maybe if u want u can do JFrame.remove(pola[i]);
where JFrame is the frame you are using and if you want it to be interactable again you add it JFrame.add(pola[i]);