Tuesday, 29 November 2016

Program to display table of 1 to 10 on applet

This Java example displays the table of 1 to 10 numbers on applet.


PROGRAM
import java.applet.Applet;
import java.awt.*;

public class Table1To10Applet extends Applet {

 public void paint(Graphics g) {
  
  setBackground(Color.cyan);
  setForeground(Color.red);
  Font f=new Font("Cambria",Font.BOLD,16);
  g.setFont(f);
  
  int x=20,y=20;
  for(int i=1;i<=10;i++)
  {
   for(int j=1;j<=10;j++)
   {
    int k=i*j;
    g.drawString(k+"",x,y);
    x=x+30;
   }
   x=20;
   y=y+30;
  }
 }
}

/* <applet class="" width="350" height="350">
   </applet> */

OUTPUT

C:\>javac Table1To10Applet.java
C:\>appletviewer Table1To10Applet.java



No comments:

Post a Comment