Bonjour,

Voici mon problème... J'ai fait ce code pour avoir un affichage de JLabels "runnable" et cela me sort plein, plein, plein d'erreurs...

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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.*;
 
 
 
@SuppressWarnings("serial")
public class Jeu extends JFrame implements MouseListener {
 
 
	public JButton barre1 = new JButton("", new ImageIcon("barre1.gif"));
	public JButton barre2 = new JButton("", new ImageIcon("barre2.gif"));
	public JButton barre3 = new JButton("", new ImageIcon("barre3.gif"));
	public JButton barre4 = new JButton("", new ImageIcon("barre4.gif"));
	public JButton champ1 = new JButton("", new ImageIcon("champ.png"));
	public JButton champ2 = new JButton("", new ImageIcon("champ.png"));
	public JButton rive = new JButton("", new ImageIcon("riviere.bmp"));
 
	public JComboBox Menu1 = new JComboBox();
 
 
 
 
 
 
	// déclaration variables
 
	public int ClickX = 0;
	public int ClickY =0;
	public byte nombreDeDoodeVert=7;	
	public byte nombreDeDoodeBleu=8;
	public byte nombreDeDoodeRouge=4;
	public byte nombreDeDoodeJaune=4;
	public byte nombreEnnemis=75;
	public int nombreDeDoode=nombreDeDoodeVert+nombreDeDoodeBleu+nombreDeDoodeRouge+nombreDeDoodeJaune;
	public short doowatt=500;
	public short nourriture=500; // chercher un autre nom
	public short geleeNoire; // autre nom
	public short nombreEnnemisTues=0;
	public String pseudo;
	public Container contenu2;
	public JLabel fond;
 
 
	// Jeu
 
	public Jeu (String titre) {                 //création de la méthode constructeur
		setTitle (titre);
		Container contenu2 = getContentPane();	
		contenu2.addMouseListener(this);
 
 
 
		public JLabel BarreVert = new JLabel();
		public JLabel BarreBleu = new JLabel();
		public JLabel BarreRouge = new JLabel();
		public JLabel BarreJaune = new JLabel();
 
 
 
		public JLabel fond = new JLabel();
 
		contenu2.setLayout(null);
		Image image = Toolkit.getDefaultToolkit().createImage("map5.jpg");// nouveau JLabel backgound
		fond.setIcon(new ImageIcon(image));
 
 
 
		public void go(){
		contenu2.add(BarreVert);
		BarreVert.setText(""+nombreDeDoodeVert);
		BarreVert.setBounds(98,2,20,20);
		BarreVert.setForeground(Color.white); 
 
 
 
 
		contenu2.add(BarreBleu);
		BarreBleu.setText(""+nombreDeDoodeBleu);
		BarreBleu.setBounds(292,2,20,20);
		BarreBleu.setForeground(Color.white);
 
 
		contenu2.add(BarreRouge);
		BarreRouge.setText(""+nombreDeDoodeRouge);
		BarreRouge.setBounds(492,2,20,20);
		BarreRouge.setForeground(Color.white);
 
 
		contenu2.add(BarreJaune);
		BarreJaune.setText(""+nombreDeDoodeJaune);
		BarreJaune.setBounds(676,2,20,20);
		BarreJaune.setForeground(Color.white);
}
 
 
 
 
 
 
		contenu2.add(barre1);
		barre1.setBounds(5,5,190,55);
		barre1.setFocusPainted(false);
		barre1.setBorderPainted(false);                  // ces trois lignes enelvent la bordure du boutton
		barre1.setContentAreaFilled(false);
		barre1.addMouseListener(this); 
 
 
		contenu2.add(barre2);
		barre2.setBounds(187,5,190,55);
		barre2.setFocusPainted(false);
		barre2.setBorderPainted(false);                  // ces trois lignes enelvent la bordure du boutton
		barre2.setContentAreaFilled(false);
		barre2.addMouseListener(this);
 
 
		contenu2.add(barre3);
		barre3.setBounds(372,5,190,55);
		barre3.setFocusPainted(false);
		barre3.setBorderPainted(false);                  // ces trois lignes enelvent la bordure du boutton
		barre3.setContentAreaFilled(false);
		barre3.addMouseListener(this);
 
 
		contenu2.add(barre4);
		barre4.setBounds(557,5,190,55);
		barre4.setFocusPainted(false);
		barre4.setBorderPainted(false);                  // ces trois lignes enelvent la bordure du boutton
		barre4.setContentAreaFilled(false);
		barre4.addMouseListener(this);
 
		contenu2.add(champ1);
		champ1.setBounds(1000,500,190,55);
		champ1.setFocusPainted(false);
		champ1.setBorderPainted(false);                  // ces trois lignes enelvent la bordure du boutton
		champ1.setContentAreaFilled(false);
		champ1.addMouseListener(this);
 
		contenu2.add(champ2);
		champ2.setBounds(250,800,190,55);
		champ2.setFocusPainted(false);
		champ2.setBorderPainted(false);                  // ces trois lignes enelvent la bordure du boutton
		champ2.setContentAreaFilled(false);
		champ2.addMouseListener(this);
 
		contenu2.add(rive);
		rive.setBounds(0,0,190,55);
		rive.setFocusPainted(false);
		rive.setBorderPainted(false);                  // ces trois lignes enelvent la bordure du boutton
		rive.setContentAreaFilled(false);
		rive.addMouseListener(this);
 
 
 
 
		contenu2.add(fond);
		fond.setBounds(0, 0, 1280, 1024);
 
 
 
		setSize(1280,1024);
		setResizable(false);
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setVisible(true);
 
 
 
 
	}
 
 
 
 
 
 
 
 
 
	public void mouseClicked(MouseEvent e) {	
		Object source = e.getSource();	
		if (source != barre1){
 
			ClickX = e.getX();
			ClickY = e.getY();
			System.out.print("\nla variable est à:"+ClickX+" et à "+ClickY);
			nombreDeDoodeRouge++;
 
 
		}
 
 
 
	}
 
 
 
 
 
 
 
 
	public void mouseEntered(MouseEvent arg0) {
 
 
	}
 
 
	public void mouseExited(MouseEvent arg0) {
 
 
	}
 
 
	public void mousePressed(MouseEvent Pressevt) {
 
 
	}
 
 
 
 
	public void mouseReleased(MouseEvent arg0) {
 
 
	}
	class PlayAnimation implements Runnable{
 
        @Override
        public void run() {
                go();          
}

erreurs:
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problems: 
	Duplicate field Jeu.fond
	Syntax error, insert "}" to complete MethodBody
	Duplicate field Jeu.fond
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "null", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "setIcon", = expected after this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "barre1", VariableDeclaratorId expected after this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on tokens, delete these tokens
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "false", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "false", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "false", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "this", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "barre2", VariableDeclaratorId expected after this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on tokens, delete these tokens
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "false", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "false", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "false", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "this", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "barre3", VariableDeclaratorId expected after this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on tokens, delete these tokens
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "false", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "false", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "false", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "this", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "barre4", VariableDeclaratorId expected after this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on tokens, delete these tokens
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "false", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "false", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "false", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "this", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "champ1", VariableDeclaratorId expected after this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on tokens, delete these tokens
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "false", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "false", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "false", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "this", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "champ2", VariableDeclaratorId expected after this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on tokens, delete these tokens
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "false", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "false", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "false", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "this", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "rive", VariableDeclaratorId expected after this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on tokens, delete these tokens
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "false", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "false", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "false", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "this", delete this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on token "fond", VariableDeclaratorId expected after this token
	Syntax error on token(s), misplaced construct(s)
	Syntax error on tokens, delete these tokens
	Syntax error on token(s), misplaced construct(s)
	Syntax error on tokens, AnnotationName expected instead
	Syntax error on token ";", @ expected
	Syntax error on token ";", @ expected
	Syntax error on token "}", delete this token
 
	at Jeu.<init>(Jeu.java:46)
	at Menu.actionPerformed(Menu.java:83)
	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)