I am trying to make a JDialog that will show the user a dynamic message in JLabel. The message should be a number from 1 to 10 (and it should change the number of times per second). the fact is that when im debugs it - it stops right after "dia.setVisible (true)" ;, and will not continue if I do not close JDialog. Is there any possible way to fix it? Thank.
Take a look at the code:
@Override
public void run() {
dia = new JDialog(parentDialog, true);
dia.setLocationRelativeTo(parentFrame);
String text = "Text ";
dia.setSize(300, 150);
jl = new JLabel(text);
dia.getContentPane().add(jl);
dia.setVisible(true);
for (int i = 0; i < 10; i++) {
try {
Thread.sleep(1000);
jl.setText(text + " " + i);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
source
share