Sommaire TDM |
Ecriture du programme
HelloWorld.java
import java.applet.Applet; import java.awt.Graphics; public class HelloWorld extends Applet { public void paint(Graphics g) { g.drawString("Hello world!", 50, 25); } }Compilation du programme
CompilationRésultat :
HelloWorld.class
(code source =HelloWorld.java
).
Création de la page HTML avec appel de l'applet
Hello.html
HelloWorld.class
. Résultat :<HTML> <HEAD> <TITLE> A Simple Program </TITLE> </HEAD> <BODY> Here is the output of my program: <APPLET CODE="HelloWorld.class" WIDTH=150 HEIGHT=25> </APPLET> </BODY> </HTML>Exécution de l'Applet
Once you've successfully completed these steps, you should see something like this in the browser window: