Programming Tutorials

Java program to display numbers from 1 to 10 on Applet

By: Paawan Chaudhary in Java Tutorials on 2012-09-19  

This is a Java program to display numbers from 1 to 10 on Applet such that each number will be displayed after delay of 100ms.

import java.applet.*;
import java.awt.*;
/*
<applet code="Numbers.class" width=300 height=300>
</applet> 
*/

public class Numbers extends Applet
{
	public void paint(Graphics g)
	{
	   try
	   {
		for(int i = 1; i <= 10; i ++)
		{
			g.drawString(String.valueOf(i), 100, 100 + (i * 15));
			Thread.sleep(100);
		}
	   }
	   catch(InterruptedException e)
	   {
		System.out.println(e);
	   }
	}
}





Add Comment

* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in Java )

Latest Articles (in Java)