Created
June 29, 2009 07:17
-
-
Save jonasbjork/137511 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Klocka.java | |
import java.awt.*; | |
import java.util.Date; | |
public class Klocka extends java.applet.Applet | |
implements Runnable { | |
Font teckensnittet=new | |
Font("Helvetica",Font.BOLD,18); | |
Date tiden; | |
Thread trad; | |
public void start(){ | |
if(trad==null){ | |
trad=new Thread(this); | |
trad.start(); | |
} | |
} | |
public void stop(){ | |
if(trad!=null){ | |
trad.stop(); | |
trad=null; | |
} | |
} | |
public void run(){ | |
while(1<2){ | |
tiden=new Date(); | |
repaint(); | |
try { | |
Thread.sleep(1000); | |
} catch (InterruptedException e){} | |
} | |
} | |
public void paint(Graphics g){ | |
g.setFont(teckensnittet); | |
g.drawString(tiden.toString(),10,30); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment