Date d = new Date(); g.drawString(d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds(), 1, 10);
while (timerThread != null) { repaint(); // request a redraw try { timerThread.sleep(1000); } catch (InterruptedException e){ /* do nothing*/ } }
timerThread = new Thread(this, "Clock"); timerThread.start();
if (timerThread == null) return; timerThread.stop(); timerThread = null;