Professional Documents
Culture Documents
Date:06/11/2020
JAVA APPLET
1. Init( )
2. Start( )
3. Stop( )
4. Destroy( )
5. Paint( )
Example :HelloWorldApplet.java
These import statements bring the classes into the scope of our
applet class − java.applet.Applet
java.awt.Graphics
Without those import statements, the Java compiler would not
recognize the classes Applet and Graphics, which the applet class
refers to.
Invoking an Applet
•An applet may be invoked by embedding directives in an
HTML file and viewing the file through an applet viewer or
Java-enabled browser.
•The <applet> tag is the basis for embedding an applet in an
HTML file. Following is an example that invokes the "Hello,
World" applet.
Process of creating an Applet is – 7M
1. Building an applet code(.java file)
2. Creating an executable applet(.class file)
3. Designing a web page using HTML page
4. Preparing </APPLET> tag
5. Incorporating </APPLET> tag into the web page.
6. Creating HTML file
7. run your applet
Process of creating an Applet is
1.Building an applet code(.java file) AppletClass.java
import java.applet.*;
import java.awt.*;
public class AppletClass extends Applet
{
public void paint (Graphics g)
{
g.drawString (“Creation of Applet", 30, 30);
}
}
Process of creating an Applet is
2.Creating an executable applet(.class file)
Example:
<applet code=“AppletClass” width=300 height=50>
</applet>
Process of creating an Applet is
5. Incorporating </APPLET> tag into the web page
There are two ways to incorporate applet tag:
(i) Creating HTML FILE with applet tag and
running it in browser.
Here the applet tag is inserted into the HTML code.
<html>
<head>
<title>creation of an applet</title>
</head>
<body>
<applet code=“AppletClass” width=300 height=50></applet>
</body>
</html>
import java.applet.*;
import java.awt.*;
/*<applet code=“AppletClass” width=300 height=50><
/applet>*/
public class AppletClass extends Applet
{
public void paint (Graphics g)
{
g.drawString (“Creation of Applet", 30, 30);
}
}
Process of creating an Applet is
5. Incorporating </APPLET> tag into the web page