import java.applet.Applet

publicité
import java.applet.Applet;
import java.awt.Color;
public class FirstApplet extends Applet{
public void init(){
this.setBackground(Color.YELLOW);
}
}
1
<html>
<head>
<title> A Simple Program </title>
</head>
<body>
<p>
Here is the output of my program: </p>
<applet code="FirstApplet.class" width="150" height
</applet>
</body>
</html>
2
3
import java.applet.*;
import java.awt.Color;
import java.net.URL;
public class SecondApplet extends Applet{
AudioClip ac;
public void init(){
showStatus("init commence");
try{
ac = getAudioClip(new URL(getCodeBase()
}catch(Exception e){
}
showStatus("init termine");
}
public void start(){
showStatus("start commence");
ac.loop();
}
public void stop(){
showStatus("stop commence");
4
ac.stop();
}
}
5
import java.applet.Applet;
import java.awt.Graphics;
public class HelloWorld extends Applet {
public void paint(Graphics g) {
g.drawString("Hello world!", 50, 25);
}
}
6
import java.applet.*;
import java.net.URL;
import java.awt.*;
public class Communication extends Applet{
String nombre;
String nom;
TextArea ta = new TextArea(10,60);
public void init(){
nombre = getParameter("Nombre");
nom = getParameter("Nom");
add(ta);
}
public void start(){
ta.append("le nombre est " + nombre + "\n")
ta.append("le nom est " + nom + "\n");
ta.append("URL de la classe : " + getCodeBa
ta.append("URL du document : " + getDocumen
}
}
7
<html>
<head>
<title> A Simple Program </title>
</head>
<body bgcolor="#DADADA">
<p>
Voici l’applet qui s’exécute.
<br/>
<applet code="Communication.class" width="800" heig
<param name="Nombre" value="125">
<param name="Nom" value="Paul-Andre">
</applet>
<br/>
Et oui, c’est ainsi.
</p>
</body>
</html>
8
9
Téléchargement