Salut, je viens de vouloir transformer une de mes appli en applet mais malgré aucune erreur à la compilation,revu et revu mon code ... rien n'y fait !
voici le code d'appel en appel juqu'à la Jframe à afficher ... si le coeur vous en dit ! ;-)

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
<!DOCTYPE HTML>
 
<HTML>
      <HEAD>
      </HEAD>
  <BODY>
   <APPLET CODE="BioStart.class" WIDTH=250 HEIGHT=350></APPLET>
  </BODY>
</HTML>
qui appele :

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
import javax.swing.*;
 
 
 
public class BioStart extends JApplet{
 
 
 
  public void init(){}
 
 
  public void start () {
 
 
 
	BioFrame Bioritmik=new BioFrame();
	Bioritmik.reset();
	Bioritmik.show();
  }
 
  public void stop(){}
 
  public void destroy(){}
 
 
}

qui apelle:


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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
 
 
// BioFrame.java
import javax.swing.JApplet;
import javax.swing.* ;
import java.awt.* ;
import java.lang.String;
import java.util.Vector;
 
 
/**
 * définition de la classe BioFrame
 */
 
public class BioFrame extends JApplet {
 
 
 
 
public static final int SommeilNeg =  1; // valeur bouton - du poste Sommeil   somN
public static final int TravailNeg =  2; // valeur bouton - du poste Travail   traN
public static final int LoisirsNeg =  3; // valeur bouton - du poste Travail   loiN
public static final int AmourNeg   =  4; // valeur bouton - du poste Travail   amN
public static final int SanteNeg   =  5; // valeur bouton - du poste Travail   sanN
 
public static final int SommeilPos = 11; // valeur bouton + du poste Travail	somP
public static final int TravailPos = 22; // valeur bouton + du poste Travail	traP
public static final int LoisirsPos = 33; // valeur bouton + du poste Travail	loiP
public static final int AmourPos   = 44; // valeur bouton + du poste Travail	amP
public static final int SantePos  =  55; // valeur bouton + du poste Travail	sanP
 
public static final int Transaction = 100; //connection-MiseàJour-déconnection   trans
 
public static final int Precedent = 101;   //navigation prec
public static final int Suivant   = 102;              //suiv:
 
 
 
 
public JLabel log;
public static JTextField login;
 
public JLabel pass;
public static JTextField passwd;
 
public JLabel conseil;
public static TextArea leconseil;
 
public JLabel date;
public static JLabel ladate;
 
public JLabel sommeil;
public JLabel travail;
public JLabel loisirs;
public JLabel amour;
public JLabel sante;
 
public ControlButton somN ;
public ControlButton traN ;
public ControlButton loiN ;
public ControlButton amN   ;
public ControlButton sanN   ;
 
 
public static JLabel cotsommeil;
public static JLabel cottravail;
public static JLabel cotloisirs;
public static JLabel cotamour;
public static JLabel cotsante;
 
public ControlButton somP ;
public ControlButton traP ;
public ControlButton loiP ;
public ControlButton amP   ;
public ControlButton sanP   ;
 
//----------- Boutons Navigation
public ControlButton prec;
public ControlButton suiv;
 
//----------- Boutons Connection/mise à jour/quitter
public static ControlButton trans;
 
//----------- Label des messages d'erreurs
public static JLabel error;
 
 
 
public GridBagLayout GridBagLay;
public GridBagConstraints gridBagCons = new GridBagConstraints();
 
 
/* CONSTRUCTEUR
*
* @pre -
* @post une instance de la classe BioFrame est crée avec
*       un bouton étiqueté "Connection"
*       un bouton étiqueté "Jour précédent"
*       un bouton étiqueté "Jour suivant"
*       avec leur étiquette d'identification unique
*       mise en place par/dans un GridBagLayout
*/
 
public BioFrame(){
    GridBagLay = new GridBagLayout();
	getContentPane().setLayout(GridBagLay); //setLayout(GridBagLay);
 
 
	log = new JLabel(" Login:");
	login = new JTextField(5);
 
 
	pass = new JLabel(" Password:");
	passwd = new JTextField(5);
 
 
	date = new JLabel(" date consultée:");
    ladate = new JLabel("00/00/0000");
 
	conseil = new JLabel(" Le conseil du jour:");
	leconseil = new TextArea("En attente de votre identification",4,10,TextArea.SCROLLBARS_VERTICAL_ONLY);
 
 
	sommeil = new JLabel("        Sommeil");
	travail = new JLabel("        Travail");
	amour   = new JLabel("        Amour");
    sante   = new JLabel("        Santé");
    loisirs = new JLabel("        Loisirs");
 
    sommeil.setForeground(Color.blue);
	travail.setForeground(Color.blue);
	amour.setForeground(Color.blue);
	sante.setForeground(Color.blue);
    loisirs.setForeground(Color.blue);
 
    cotsommeil = new JLabel("0");
	cottravail = new JLabel("0");
	cotamour   = new JLabel("0");
	cotsante   = new JLabel("0");
	cotloisirs = new JLabel("0");
 
	cotsommeil.setForeground(Color.blue);
	cottravail.setForeground(Color.blue);
	cotamour.setForeground(Color.blue);
	cotsante.setForeground(Color.blue);
    cotloisirs.setForeground(Color.blue);
 
	// les boutons mis sur écoute
 
    somN = new ControlButton("-",SommeilNeg);
    somP = new ControlButton("+",SommeilPos);
 
    traN = new ControlButton("-",TravailNeg);
    traP = new ControlButton("+",TravailPos);
 
    loiN = new ControlButton("-",LoisirsNeg);
    loiP = new ControlButton("+",LoisirsPos);
 
    amN = new ControlButton("-",AmourNeg);
    amP = new ControlButton("+",AmourPos);
 
    sanN = new ControlButton("-",SanteNeg);
    sanP = new ControlButton("+",SantePos);
 
	// les boutons de "navigation" mis sur écoute
 
    prec = new ControlButton("jour précédent",Precedent);
	suiv = new ControlButton("jour suivant",Suivant);
 
	trans = new ControlButton(" ",Transaction);
 
	error = new JLabel("");
	error.setForeground(Color.blue);
 
 
	makeLayout(log,1,1);
	makeLayout(login,2,1);
	makeLayout(pass,1,2);
	makeLayout(passwd,2,2);
 
	makeLayout(date,1,3);
	makeLayout(ladate,2,3);
	makeLayout(conseil,1,4);
	makeLayout(leconseil,2,4);
 
 
 
 
 
	makeLayout(sommeil,1,7);makeLayout(somN,2,7);makeLayout(cotsommeil,2,7);makeLayout(somP,2,7);
	makeLayout(travail,1,8);makeLayout(traN,2,8);makeLayout(cottravail,2,8);makeLayout(traP,2,8);
	makeLayout(amour,1,9);makeLayout(loiN,2,9);makeLayout(cotloisirs,2,9);makeLayout(loiP,2,9);
	makeLayout(sante,1,10);makeLayout(amN,2,10);makeLayout(cotamour,2,10);makeLayout(amP,2,10);
	makeLayout(loisirs,1,11);makeLayout(sanN,2,11);makeLayout(cotsante,2,11);makeLayout(sanP,2,11);
 
 
	makeLayout(prec,1,14);
	makeLayout(suiv,2,14);
 
    makeLayout(trans,2,16);
 
    makeLayout(error,1,16);
 
 
	}//fin Constructeur
 
 
//----------------------------------------------------------------------------
 
public void makeLayout(JLabel label, int x, int y) {
 
	  //String nom=((JLabel)label).getName(); marche pas !!?! grrrr
	  String nom=label.getText(); // astuce mais moins garanti ... trilili
	  ////System.out.println (nom);
 
	  gridBagCons.gridx = x;
	  gridBagCons.gridy = y;
 
	  if ( (nom=="0") || (nom=="0") || (nom=="0") || (nom=="0") || (nom=="0")){
		  gridBagCons.anchor = GridBagConstraints.CENTER;
		  gridBagCons.fill = GridBagConstraints.RELATIVE;
		  gridBagCons.weightx = 3;
	      gridBagCons.weighty = 3;
		  }
	  else {
 
		    //gridBagCons.anchor = GridBagConstraints.BOTH;
		    gridBagCons.fill = GridBagConstraints.BOTH;
			gridBagCons.weightx = 3;
	        gridBagCons.weighty = 3;
		    }
 
 
	  GridBagLay.setConstraints(label,gridBagCons);
	  getContentPane().add(label);
  }
 
public void makeLayout(JTextField tx, int x, int y) {
	  gridBagCons.gridx = x;
	  gridBagCons.gridy = y;
	  gridBagCons.fill = GridBagConstraints.BOTH;
	  gridBagCons.weightx = 3;
	  gridBagCons.weighty = 3;
	  GridBagLay.setConstraints(tx,gridBagCons);
	  getContentPane().add(tx);
  }
 
public void makeLayout(TextArea txAr, int x, int y) {
	  gridBagCons.gridx = x;
	  gridBagCons.gridy = y;
	  //gridBagCons.fill = GridBagConstraints.BOTH;
	  gridBagCons.weightx = 3;
	  gridBagCons.weighty = 3;
	  GridBagLay.setConstraints(txAr,gridBagCons);
	  getContentPane().add(txAr);
  }
 
 
 
public void makeLayout(ControlButton cb, int x, int y) {
	  int id=cb.getIdentification();
	  ////System.out.println (id);
 
	  gridBagCons.gridx = x;
	  gridBagCons.gridy = y;
 
	  if ((id>0) && (id<10))   {gridBagCons.anchor = GridBagConstraints.WEST;
	                            gridBagCons.fill = GridBagConstraints.RELATIVE;
	  						    gridBagCons.weightx = 1;
	                            gridBagCons.weighty = 1;
 
	                          }
	  if ((id>10) && (id<100)) {gridBagCons.anchor = GridBagConstraints.EAST;
	  							gridBagCons.weightx = 1;
	                            gridBagCons.weighty = 1;
 
 
	                          }
	  if (id>=100) {gridBagCons.anchor = GridBagConstraints.CENTER;
	                            gridBagCons.fill = GridBagConstraints.BOTH;
	                            gridBagCons.weightx = 3;
								gridBagCons.weighty = 3;
 
	                 }
 
 
	  GridBagLay.setConstraints(cb,gridBagCons);
	  getContentPane().add(cb);
  }
 
 
 
public void setLabel(JLabel label, String text){
 
	label.setText(text);
 
}//fin setLabel
 
public void setLabel(ControlButton boutton, String text){
 
	boutton.setText(text);
 
}//fin setLabel
 
public void reset(){ // initialisation du ControlPanel
 
 
     passwd.setText("");
     login.setText("");
     ladate.setText("0000/00/00");
     leconseil.setText("En attente de votre identification");
     leconseil.setEditable(false);
     cotsommeil.setText("0");
     cottravail.setText("0");
     cotamour.setText("0");
     cotsante.setText("0");
     cotloisirs.setText("0");
     trans.setText("Connection");
     error.setText("");
     error.setForeground(Color.blue);
 
     login.requestFocus();
 
 
}//fin reset
 
}//fin BioFrame