2
I have a button that when you click it changes color, but if you click it again nothing should happen. However, I still can’t block this action. I tried that 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 disabled.
What is the initial color of the button (before any click)?
– Piovezan
No color. it only gets a color after the first click, that’s a game of old.
– Leonardo Furtado