Java first applet program to display WELCOME TO SCANFCODE

Applet program

This program illustrate the concept of applet program.

  • Applet are made in java programs that are used in internet computing.
  • Applet are embeded into webpages.
  • Their are two mehtods to embed a applet.
    1. Write your own template and embed them into webpages.
    2. Download the applet from remote computer system and then ambed it into a webpage.
  • Applet class is a subclass of panel class which is itself a subclass of container.

Java applet code

import java.util.*;
import java.awt.*;
import java.applet.*;
public class scanfcode extends Applet
{
  public void paint(Graphics g)
  {
  g.drawString("Welcome to scanfcode",100,100);
  }
}
  • Enter javac scanfcode.java to compile the program in the directory containing source code.
  • Once Your program is compiled successfully the output called scanfcode.class will made in same folder where the source code is located.

Applet program

Now design a webpage using a applet tag. Save this file in same folder by .html extension.

<html>
<head>
<title>
<p>First applet program</p>
</title>
</head>
<body>
<applet code="scanfcode.class" width="350" height="350">
</applet>
</body>
</html>

Now run this .html file in CMD using command appletviewer scanfcode.html .

Applet program

OUTPUT

Applet program


Comment below if you are facing any problem.


Also read

Java program to understand basic concept of single level inheritance
How to print a Matrice in Java in 2d array
First java program


Summary
Java first applet program to display WELCOME TO SCANFCODE
Article Name
Java first applet program to display WELCOME TO SCANFCODE
Description
This program illustrate the concept of applet program.Applet are made in java programs that are used in internet computing.
Author
Publisher Name
Scanfcode
Publisher Logo

Leave a Reply

Your email address will not be published. Required fields are marked *