I have the following code. I want to Make jLabel Visible and Invisible 4 times with 0.5Seconds delay for every loop. The code below is not working as expected.
String a = (String)jTextField1.getText();
if(a.equals("")){
for (int i = 0;i<=3;i++){
try {
jLabel1.setVisible(true);
Thread.sleep(500);
for(int j=0;j<i;j++){
jLabel1.setVisible(false);
Thread.sleep(500);
}
} catch (InterruptedException ex) {
}
}
}