Bonjour pourrez vous me dire pourquoi cet Applet ne fonctionne pas?
est-ce la méthode init qui est manquante?
le programme doit dessinner 12 carré différents dans l'applet qui se chevauche... merci de vos réponses.
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
public class Descar extends Applet implements Runnable {
	private int blue, red, green, rgb, i=0;
	private int longueur,hauteur=0;
	private int x,y=0;
	private boolean arret=false;
 
	public void start(){
	this.arret=false;
	(new Thread(this)).start();}
	public void stop(){
		this.arret=true;
	}
	public void run(){
		while(true){
			this.paint(this.getGraphics());
			try{
				Thread.sleep(5000);
			}
			catch (Exception e){
 
			}
			if(this.arret==true){
				return;
			}
		}
	}
	public void changeCoul(){
		rgb=255*(int)Math.random();		
	}
	public void changeDim(){
		x=100*(int)Math.random();
		y=100*(int)Math.random();
		longueur=hauteur=30*(int)Math.random();
	}
	public void paint(Graphics ga){
		this.changeCoul();
		red=rgb;
		this.changeCoul();
		blue=rgb;
		this.changeCoul();
		green=rgb;
		this.changeDim();
	ga.setColor(new Color(red, green, blue));
	ga.drawRect(x,y,longueur,hauteur);
	ga.fillRect(x,y,longueur,hauteur);
 
	}
 
}
voici le code de l'applet

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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 
<html>
<head>
	<title>applet java</title>
</head>
 
<body>
<applet code="Descar.class" width="300" height="300">
pas de java
</applet>
 
 
</body>
</html>
merci à tous d'avance;.. [/quote]