Q:

Java Applet - Model Digital Clock Demo

0

This Program is used to demonstrate the Digital Clock Model Program using Java Applet.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

// 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> */

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now