I have a button that when clicking it changes color, but if you click it again nothing should happen. But I still can not block this action. I tried this code:
private void Button1_1ActionPerformed(java.awt.event.ActionEvent evt) {
if(TextoJogador.getText().equals("Jogador 1")){
Button1_1.setBackground(Color.CYAN);
TextoJogador.setText("Jogador 2");
play(sound);
}else{
Button1_1.setBackground(Color.GREEN);
TextoJogador.setText("Jogador 1");
play(sound);
}
Button1_1.setEnable(false); //essa parte que faz o button perder a cor
}
but the button loses the color that was selected when it was disabled.