I want to make a for loop wait until my other desired task is performed. In my case i want to validate a component within a loop and then increment the counter…
for(int i = 1; i<=56; i++)
{
jl.setIcon(new ImageIcon(ImageIO.read(new File("C:\\``Documents and Settings\\Prasad\\My Documents\\My Pictures\\"+Integer.toString(i)+".png"))));
jl.revalidate();
}
so here I want to open the images and validate the JLabel every time the loop runs. What happens is the images are loaded but the one displayed is only the last one. i.e. “56.png” the others are not!!!
So is there any solution to this?? Please help me!!
All help is appreciated…
When you load an Image, you can attach an ImageObserver to that image to be notified when various stages in the loading have happened. For more detailed information, look at this tutorial.
If you’re running loops in your GUI code, you’re almost certainly doing something wrong.