Skip to content

Instantly share code, notes, and snippets.

@jonasbjork
Created June 29, 2009 07:17
Show Gist options
  • Save jonasbjork/137511 to your computer and use it in GitHub Desktop.
Save jonasbjork/137511 to your computer and use it in GitHub Desktop.
// 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