Professional Documents
Culture Documents
Java Applet
Java Applet
Open the
Write the
Write a HTML
Java
Compile HTML to file in
Applet
it call the browser
Source
Applet and run
Code
it
Write the Java Applet Source Code
import java.applet.Applet;
import java.awt.Graphics;
public class HelloWorldApplet extends Applet
{
public void paint(Graphics g)
{
g.drawString("Hello world!", 50, 25);
}
}
Compile it
<html>
…….
<applet CODE=“HelloWorldApplet.class"
WIDTH="250"
HEIGHT="220">
</applet>
……
</html>
Open the HTML file in browser and run it
• import java.applet.*;
• import java.awt.*;
• • Applet enters into running state when it calls start() method • The
start( ) method is called after init( ) • It is also called to restart an
applet after it has been stopped • Where as init( ) is called only once,
start() method may be called any number of times • When a user
leaves a web page and comes back, the applet resumes execution