View Single Post
  #1 (permalink)  
Old 05-11-2008, 04:43 AM
gleb gleb is offline
Member
 
Join Date: May 2008
Posts: 3
gleb is on a distinguished road
Please Help Me FLASH
Hello, I hope someone can help my get an image in my JPanel flash (on/off) at a predetermined time interval.
For instance, I want it to flash on/off every second. I tried writing the code within a thread like:

class..... extends Thread
.
.
try{
for(int i = 0; i < 10000; i++){
panel.add(image);
Thread.sleep(1000);
panel.remove(image); //panel.add(noImage)
}
}catch InterruptedException e)......

But this only seems to wait the one (1) second until the program runs, and it doesn't actually paint the image. Also, as the image would be removed, I know that all other components would collapse and get funky, so I created another image that is the color of the background, and tried the same thing with it (it's commented) as well as removed it. But the program still idles, and doesn't paint images. I hope someone has a snippet of code or at least share a pointer with me to get me going. I'm a beginner, and any help would be appreciated. Thank you, Gleb
Reply With Quote
Sponsored Links