Bananatank Vampire

Joined: 14 May 2008 Posts: 465
HP: 5 MP: 0 Lives: 0
|
Posted: Fri Feb 13, 2009 10:11 pm
|
|
|
| Code: | import java.applet.Applet; import java.awt.Graphics; import java.util.Date;
public class ClockApplet extends Applet implements Runnable { Thread thread; String time=""; public void init() { thread=new Thread(this); setSize(40,20); thread.start(); } public void run() { while(true) { Date clock=new Date(); time=clock.getHours()+":"+clock.getMinutes()+":"+clock.getSeconds(); repaint(); try { thread.sleep(200); } catch (InterruptedException e) {} } } public void paint(Graphics g) { g.drawString(time,5,10); } public void stop() { thread.stop(); } }
|
Save as ClockApplet.java and run. That my friends is called a program. |
|