I'm making simple game with very simple thread (1 sec delay)
got problem with the thread, I have while(true)
loop with the code:
try {
while (true) {
Ltimer.setText(getTimeElapsed());
Thread.currentThread();
Thread.sleep(1000); // Thread sleeping for 1 second
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "error with timer");
}
it simply get string every second and updates label text
when I'm trying to run it the gui freeze and I can only see the label in a black background, all buttons and bg img dissappeared. tried to fix with
setVisible()
repaint()
but got nothing..
any other options?