Applet is a tag in html that is used to create an applet window or applet in an html document.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML applet Tags and their attributes</title>
</head>
<body>
<applet code="classname.class" width="300" height="200">
</applet>
</body>
</html>
e.g. <applet code="abc.class" width="200" height="200" />
Height : This attribute takes values in pixels to define the height of the applet.
Width : This attribute takes values in pixels to define the width of the applet.
Vspace : This attribute takes values in pixels to specify how much space is to be left above and below the object.
Hspace : This attribute takes values in pixels to specify how much space is to be left to the right and left of the object.
Align : This attribute is used to align the object in the applet.
Title : This attribute takes a string in input which is a title name or short information about the applet. This information is shown as a tooltip which pops when the move is brought over the applet.
Example
<!DOCTYPE html>
<html>
<head>
<title>Example of Line in the applet</title>
</head>
<body>
<applet code="designline.class" width="300" height="200">
</applet>
</body>
</html>
Here is the designline.java file:
import java.applet.*;
import java.awt.*;
public class designline extends Applet
{
public void paint (Graphics gh)
{
gh.drawLine(10,10,200,200);
}
}
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML applet Tags and their attributes</title>
</head>
<body>
<applet code="classname.class" width="300" height="200">
</applet>
</body>
</html>
Applet tag has following attributes
Code : This attribute takes the class name of the applet code that is to be displayed . Class is the compiled code for applete.g. <applet code="abc.class" width="200" height="200" />
Height : This attribute takes values in pixels to define the height of the applet.
Width : This attribute takes values in pixels to define the width of the applet.
Vspace : This attribute takes values in pixels to specify how much space is to be left above and below the object.
Hspace : This attribute takes values in pixels to specify how much space is to be left to the right and left of the object.
Align : This attribute is used to align the object in the applet.
Title : This attribute takes a string in input which is a title name or short information about the applet. This information is shown as a tooltip which pops when the move is brought over the applet.
Example
<!DOCTYPE html>
<html>
<head>
<title>Example of Line in the applet</title>
</head>
<body>
<applet code="designline.class" width="300" height="200">
</applet>
</body>
</html>
Here is the designline.java file:
import java.applet.*;
import java.awt.*;
public class designline extends Applet
{
public void paint (Graphics gh)
{
gh.drawLine(10,10,200,200);
}
}