Escolar Documentos
Profissional Documentos
Cultura Documentos
What is an Applet?
An applet is a Java program that runs on a web
page
Applets can be run within any modern browser
To run modern Java applets, old browsers need an upto-date Java plugin
appletviewer is a program that can run applet.
Applets
An applet is a Java class that extends the
java.applet.Applet class.
A main() method is not invoked on an applet,
and an applet class will not define main().
Applets are designed to be embedded within
an HTML page.
When a user views an HTML page that contains
an applet, the code for the applet is download
to the user's machine.
A JVM is required to view an applet. The JVM
can be either a plug-in of the Web browser or a
separate runtime environment.
void start()
void stop()
void destroy()
AppletContext
getAppletContext()
String getAppletInfo()
Methods.
URL getCodeBase()
URL getDocumentBase()
String
getParameter(String name)
boolean isActive()
void resize(Dimension d)
void resize(int width, int height) Requests that this applet be resized.
Paint method
This method is of java.awt.Graphics class.
Which is used to display context into the
applet.
You have implement paint( ) into every applet.
This method is called by start( ) method.
Simple example of an applet.
Example for lifecycle of an applet.
Graphics class
The graphics class is member of java.awt
package.
Contains several methods that can help to
perform graphics related operations.
Methods.
void drawArc(int x, int y, int
width, int height, int startangle,
int endangle)
void fillPolygon(int x[], int y[], int Fills a polygon using the current color.
numofpoints)
Rectangle
drawRect(int x, int y, int width, int height)
drawRect(10,10, 100, 90)
Oval
drawOval(int x, int y, int width, int height)
drawOval(10,10, 100, 90)
Arc
drawArc(int x, int y, int width, int height, int
startAngel, int endAngel)
drawArc(10,10, 100, 90)
fillArc(int x, int y, int width, int height, int startAngel,
int endAngel)
fillArc(150,10, 100, 90)
Arc
drawArc(int x, int y, int width, int height, int
startAngel, int endAngel)
drawArc(10,10, 100, 90)
fillArc(int x, int y, int width, int height, int startAngel,
int endAngel)
fillArc(150,10, 100, 90)