Unformatted text preview: timer = new Timer() //TimerTask, 0-start immediately, every second timer.schedule(this, 0, 1*MillSecondsPerSecond) // schedule method works with TimerTask, not Thread object. } public void run() { Date time = new Date() Graphics g = cont.getGraphics() //delete the previous time g.setColor(Color.white) g.drawString(clockFace, 10, 20) //get a new time and draw it clockFace = time.toString() g.setColor(Color.blue) g.drawString(clockFace, 10, 20) } }...
View
Full Document
- Spring '09
- Balasooriya/Kouvetakis
- Object-Oriented Programming, Subroutine, private Timer timer, TimerTask
-
Click to edit the document details