Voici le programme Hand.java :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import java.applet.*;
import java.awt.*;
import java.net.URL;
 
public class Hand extends Applet implements Runnable {
	Font font=new Font("Helvetica",Font.BOLD,25);
	Thread signeThread = null;
	Image patcheur[] = new Image[3];
	int LargeurImage,HauteurImage;
	int b = 0;
	boolean playing = true;
	AudioClip aC = null;
 
	public void init() {
		setBackground(Color.white);
		try{
			aC = getAudioClip(new URL(getDocumentBase(),"melo1.au"));
		}
		catch(java.net.MalformedURLException e) {}
		if(aC != null)
			aC.loop();
		for(int i=0;i<3;i++) {
			patcheur[i] = getImage(getDocumentBase(),"Hand"+i+",.jpg");
		}
 
		LargeurImage = 150;
		HauteurImage = 150;
 
		signeThread = new Thread(this);
		signeThread.start();
	}
 
	public void run() {
		while(true) {
			try{
				signeThread.sleep(500);
			} catch(InterruptedException e) {
				System.out.println("interrupted");
			}
			repaint();
			b++;
			if(b>3)
				b = 0;
		}
	}
 
	public void stop() {
		aC.stop();
		signeThread.stop();
	}
 
	public boolean mouseDown(Event evt,int xPos,int yPos) {
		if(xPos>75 && xPos<175 && yPos>75 && yPos<175) {
			if(playing ==true) {
				aC.stop();
				playing = false;
			}
			else if(playing == false) {
				aC.loop();
				playing =true;
			}
		}
	return true;
	}
 
	public void paint(Graphics g) {
		g.setFont(font);
		if(b==0) {
			g.drawImage(patcheur[0],40,40,LargeurImage,HauteurImage,this);
			g.setColor(Color.red);
			g.drawString("Hello World",10,30);
		}
		if(b==1) {
			g.drawImage(patcheur[1],40,40,LargeurImage,HauteurImage,this);
			g.setColor(Color.blue);
			g.drawString("Hello World",100,220);
		}
		if(b==2) {
			g.drawImage(patcheur[2],40,40,LargeurImage,HauteurImage,this);
			g.setColor(Color.pink);
			g.drawString("Hello World",100,30);
		}
		if(b==3) {
			g.drawImage(patcheur[1],40,40,LargeurImage,HauteurImage,this);
			g.setColor(Color.darkGray);
			g.drawString("Hello World",10,220);
		}
	}
}
En tant que novice,donnez-moi s'il vous-plaît le programme HTML correspondant.
Sachant que l'applet joue en boucle un fichier sonore,cependant qu'une main vous fait signe et qu'une bannière "Hello World" s'affiche en différentes couleurs et en différentes points de la fenêtre.
Merci