digibutter.nerr Forum Index
Hey [you]! If you haven't noticed, this is now the old digibutter forums. Go over to the new site!
digibutter.nerr
It's Hi-Technicaaal!

I MADED SUMFING
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    digibutter.nerr Forum Index -> Off-Topic
Author Message
Bananatank
Vampire


Joined: 14 May 2008
Posts: 465

HP: 5 MP: 0 Lives: 0



PostPosted: Fri Feb 13, 2009 10:11 pm   Reply with quote

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.
Back to top
Sovietkip shop    
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    digibutter.nerr Forum Index -> Off-Topic
All times are GMT - 5 Hours
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group