Im working in Java Swing using JWindows to display images... Ive made different JLabels contain the images that I want to display.. Im removing previous added components and adding new ones to be displayed on the same JWindow.. The problem is as follows..
The code works perfectly without the sleep function. I can display all the images on different windows or on same windows upon event completion.. However when I use sleep, nothing at all gets displayed during this period...
Is there any way to implement a delay for the images like a slideshow, and have the images painted before the delay?
getContentPane().remove(startLabel);
getContentPane().add(recordLabel1, "Center");
setVisible(true);
try {
Thread.sleep(500);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
getContentPane().remove(recordLabel1);
getContentPane().add(recordLabel2, "Center");
try {
Thread.sleep(500);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
getContentPane().remove(recordLabel2);
getContentPane().add(recordLabel3, "Center");
try {
Thread.sleep(500);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
getContentPane().remove(recordLabel3);
getContentPane().add(recordLabel4, "Center");
try {
Thread.sleep(500);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
getContentPane().remove(recordLabel4);
getContentPane().add(pausedLabel, "Center");
setVisible(false);