The HTML <applet> tag use to define an applet.By using applet tag we can embed a java applet in webpage.It is not supported in html5.
When we embed an applet in webpage,first we have to save it on our server.So we a applet embeded webpage loaded by a user applet also embed on that page.Sometime these applets take time for loading.
applets have the file extension 'class'.
just like:-

*** myfirstapplet.class ***


Some applets have more than one class files and other classes require for applet to run(such as jpg.or gif image).Before embeding an applet on your page you will have to upload all files on server.

You can understand it by an simplest example :-:-


<APPLET CODE=Appletclass.class WIDTH=anInt HEIGHT=anInt>
</APPLET>


The example shows that the browser load the applet whose named Appletclass. It also specifies the width and height in pixels of the applet.


You can understand it by another example:(These applets valid only in java browsers,so some browsers do not show the results of these applets.)-:-


Here is the newClass.java file:

import java.applet.*;
import java.awt.*;
public class newClass extends Applet
{
public void paint (Graphics gh)
{
g.drawString("my first applet", 200, 100);
}
}


<!DOCTYPE html>
<html>
<head>
<title>HTML applet Tag</title>
</head>
<body>
<applet code="newapplet.class" width="200" height="100">
</applet>
</body>
</html>

Result:--

my first applet



Two HTML tags are used to applets: <Applet> and <Param>.
The <Applet> tag embeds the applet in your HTML page.
The <Param> tag is used to enter parameters for the applet.


It can be understand by simple example:-

<APPLET CODE=AppletSubclass.class WIDTH=anInt HEIGHT=anInt>
<PARAM NAME=parameter1Name VALUE=aValue>
<PARAM NAME=parameter2Name VALUE=anotherValue>
</APPLET>


The following attributes can be set for the </APPLET> tag:-

Attribute explanation example
Code Name of class file Code="myapplet.class"
height/Width=n n=Width of applet Width=200
Codebase Library where the applet is stored.
If the applet is in same directory as
your page this can be omitted.
Codebase="applets/"
Alt="Text" Text that will be shown in browsers where
the ability to show applets has been turned off.
alt="Menu Applet"
Name=Name Assigning a name to an applet can
be used when applets should
communicate with each other.
Name="starter"
Vspace=n Space over and under the applet. Vspace=20
Hspace=n Space to the left and right of applet. Hspace=40


Please comment in comment box if you understand <applet> tag and have any query regarding it.--

0 comments:

Post a Comment