3
I created a simple code for a game similar to Genius, where a random button of a set of 20 buttons starts to blink, but I can’t get an interval for the color change to be visible...
Here’s an example, basically, I just need the button color to change randomly, from 0.3 in 0.3 sec...
try{
for (int i = 0; i < 255; i++){
//define a proxima cor aleatoria
cor1 = (int)(Math.random()*255)+1;
//deveria gerar o atraso de 0,3s
Thread.sleep(300);
jButton1.setBackground(new Color (cor1,00,00));
}
}catch (InterruptedExcepetion e){}
If instead of changing the color, put a background gif? It will solve?
– Sertage
But if you want to do it the way you want, you should put this color change in a thred, to swing I would recommend a Swingworker. http://www.oracle.com/technetwork/articles/javase/swingworker-137249.html
– Sertage
Okay, I’ll take a hint.
– Andiie