Program to show “HELLO JAVA ” in Explorer using Applet

Applet is java program that can be embedded into HTML pages. Java applets runs on the java enables web browsers such as mozila and internet explorer. Applet is designed to run remotely on the client browser, so there are some restrictions on it. Applet can't access system resources on the local computer Applets are used to make the web site more dynamic and entertaining.
Steps to create and execute an applet
1. Open Notepad
2. Type the java code of program :
import java.applet.*;
import java.awt.*;
public class FirstApplet extends Applet{
public void paint(Graphics g){
g.drawString("HELLO JAVA",40,20);
}
}
Rules for creating applets
1. Every applet should be public
2. Every applet should inherit applet class
3. Save it (FirstApplet.java)
4. Compile it-
5. Create an Html Document- Open Notepad, Type the following
HTML code of the program:

save it : myapplet.html

6. Open the html file or C:\data>appletviewer myapplet.html or write the applet as comment with in java file .

No comments:

Google Search