I have a loop which shows an input dialog, process it and shows the name and picture of the student using setText and setIcon. After, I want to have at least 1-2secs of delay/pause so the user can have a look on it before it loops back to show the input dialog again on the screen.
while(true){
String box = JOptionPane.showInputDialog(null, "Scan Barcode: ");
if(box == null){
break;
}else if(box.isEmpty()){
JOptionPane.showMessageDialog(null, "Invalid Input. Please Try Again.", "Error" ,JOptionPane.ERROR_MESSAGE);
}else{
// show the student info and picture
}
//DELAY HERE before it loops back
}
I've tried Thread.sleep(n) but it seems to be working. It pauses the WHOLE program for a certain time and shows the student info and picture AND the dialog box AT THE SAME TIME. I also tried timer.schedule() , still no luck.
Thanks for the help.