I have my thread
this.clock = new JLabel();
clockThread = new Thread(new Runnable() {
public void run() {
clockRun();
}
});
clockThread.start();
this.clock.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (clockDisplayRealTime) {
clockDisplayRealTime = false;
} else {
clockDisplayRealTime = true;
}
}
});
then this will not work unless I have this System.out.println as per below I am scratching my head to find out what is wrong. please help me. thanks.
public void clockRun() {
while (true) {
System.out.println(clockDisplayRealTime);
if (clockDisplayRealTime) {
Date date = new Date();
clockRealtime = date.getTime();
this.clock.setText(sdf.format(clockRealtime));
}
}
}