Java

Java Applet - Model Digital Clock Demo

Java Applet - Model Digital Clock Demo
// Thread Example

import java.awt.*;
import java.applet.*;

public class clock1 extends Applet implements Runnable
{
int i,j,k;
Thread t;

public void init()
{
t = new Thread(this); 
t.start();
}

public void run()
{
try
{
while(true)
{
for(i=0;i<=12;i++)
{
for(j=0;j<=60;j++)
{
for(k=0;k<=60;k++)
{
repaint();
Thread.sleep(1000);
}
}
}
}
}
catch(Exception e)
{ }
}

public void paint(Graphics g)
{
String s = ""+i;
String s1 = ""+j;
String s2 = ""+k;

g.setFont(new Font("Arial",Font.BOLD,40));
g.drawString(s,100,100);
g.drawString(":",130,100);
g.drawString(s1,150,100);
g.drawString(":",170,100);
g.drawString(s2,190,100);

}
}

/*<applet code = "clock1.class" height =300 width=300>
</applet> */
Senthilvelan Sambamoorthy

Senthilvelan Sambamoorthy is working as a Professor in Department of Master of Computer Applications, Paavai Engineering College, Namakkal, Tamilnadu, India, He is Masters in Computers Applications. Having 18+ years of experience and his area of interest is Java, JSP, Servlet, J2EE, C#, PHP, Python ASP.NET, SQL Server and etc.