Java program to display numbers from 1 to 10 on Applet

By: Paawan Chaudhary Viewed: 154005 times  Printer Friendly Format    


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);
	   }
	}
}


Most Viewed Articles (in Java )

Latest Articles (in Java)

Comment on this tutorial