Java Applets and Graphics Programming: K. K. Wagh Polytechnic, Nashik-3

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 8

K. K.

Wagh Polytechnic, Nashik-3

Chapter 5

Java Applets and Graphics


Programming
Applet
• Applet is a small program which provides a Graphical User
Interface (GUI) to user.
• Applet programs are executed with a special JDK tool-
appletviewer.
Applet and Application
Sr. No. Application Applet
Applications are just like a Java Applets are small Java programs that
programs that can be execute are designed to be included with HTML
1.
independently without using web web document. They require a Java-
browser. enabled web browser for execution.

Application program requires a main Applet does not require a main function
2.
function for its execution. for its execution.

Java application programs have the full Applets don’t have local disk and
3.
access to the local file system network. network access.

Applets can only access the browser


Applications can access all kinds of
4. specific services. They don’t have
resources available on the system.
access to the local system.

Applications can executes the programs Applets cannot execute programs from
5.
from the local system. the local machine.

An application program is needed to An applet program is needed to


6.
perform some task directly for the user. perform small tasks or the part of it.
Applet Life Cycle
Applet Methods Sequence
import java.awt.*; import java.applet.*;
Applet Skeleton public class MyApplet extends Applet
{ public void init( )
{
// initializes applet
}
public void start( )
{
// start or resume execution
}
public void stop( )
{
// suspends execution
}
public void destroy( )
{
// perform shutdown activities
}
public void paint(Graphics g)
{
// redisplay contents of window
} }
Applet tag
<APPLET
[ CODEBASE = codebaseURL]
CODE = appletFile
[ ALT = alternateText]
[ NAME = appletInstanceName]
WIDTH = pixels HEIGHT = pixels
[ ALIGN = alignment]
[ VSPACE = pixels] [HSPACE = pixels] >
[< PARAM NAME = AttributeName VALUE =AttributeValue>]
[< PARAM NAME = AttributeName2 VALUE =AttributeValue>]
...
...
</APPLET>
Passing Parameters to Applet
To pass the parameters to Applet <param> tag is used.

Syntax: <param name= name value=value>

To retrieve parameters from param tag in program following


method is used:
String getParameter(String s)

You might also like