bonjour et merci d'avance
g édité une applet qui doit récupérer des taux de change de pages web et qui les met dans des jlabels mai mon problème c'est qu'elle fonctionne sur le simulateur de jbulder mai après sur le navigateur sa ne marche pas
voici mon code
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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
 
package app_devise;
 
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.awt.BorderLayout;
import java.net.URL;
import java.net.URLConnection;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.io.IOException;
import java.awt.Dimension;
import com.borland.dbswing.JdbEditorPane;
import javax.swing.border.Border;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.awt.Font;
import com.borland.jbcl.layout.*;
import javax.swing.*;
import javax.swing.JLabel;
 
public class app_devise extends Applet implements Runnable{
    boolean isStandalone = false;
 
       public String getParameter(String key, String def) {
        return isStandalone ? System.getProperty(key, def) :
                (getParameter(key) != null ? getParameter(key) : def);
    }
 
    // Construire l'applet
    public app_devise() {
    }
 
    // Initialiser l'applet
    public void init() {
        try {
            jbInit();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
    // Initialiser le composant
    Image mon_image;
    Border border1 = BorderFactory.createEmptyBorder();
    JPanel principale = new JPanel();
    BorderLayout borderLayout3 = new BorderLayout();
    BorderLayout borderLayout1 = new BorderLayout();
  JPanel jPanel1 = new JPanel();
  BorderLayout borderLayout2 = new BorderLayout();
  JPanel jPanel2 = new JPanel();
  JButton Aaudi_Arabia = new JButton();
  JButton jButton2 = new JButton();
  JLabel jLabel1 = new JLabel();
  JLabel jLabel2 = new JLabel();
  JLabel jLabel3 = new JLabel();
  JLabel jLabel4 = new JLabel();
  JLabel jLabel5 = new JLabel();
  GridBagLayout gridBagLayout1 = new GridBagLayout();
  JLabel jLabel6 = new JLabel();
  JLabel jLabel10 = new JLabel();
  JLabel jLabel11 = new JLabel();
  JLabel jLabel12 = new JLabel();
  JLabel jLabel13 = new JLabel();
  JLabel jLabel14 = new JLabel();
  JLabel jLabel15 = new JLabel();
  JLabel jLabel16 = new JLabel();
  JLabel jLabel17 = new JLabel();
  JLabel jLabel18 = new JLabel();
  JLabel jLabel19 = new JLabel();
  JLabel jLabel20 = new JLabel();
  JLabel jLabel110 = new JLabel();
  JLabel jLabel7 = new JLabel();
  JLabel jLabel8 = new JLabel();
  JLabel jLabel9 = new JLabel();
  JLabel jLabel111 = new JLabel();
  JLabel jLabel21 = new JLabel();
  JLabel jLabel22 = new JLabel();
  JLabel jLabel23 = new JLabel();
  JLabel jLabel24 = new JLabel();
  JLabel jLabel25 = new JLabel();
  JLabel jLabel26 = new JLabel();
  JLabel jLabel27 = new JLabel();
  JLabel jLabel28 = new JLabel();
  JLabel TND = new JLabel();
  JLabel AED = new JLabel();
  JLabel USD = new JLabel();
  JLabel CAD = new JLabel();
  JLabel EUR = new JLabel();
  JLabel GBP = new JLabel();
  JLabel QAR = new JLabel();
  JLabel JPY = new JLabel();
  JLabel LYD = new JLabel();
  JLabel BHD = new JLabel();
    private void jbInit() throws Exception
    {
    principale.setLayout(borderLayout2);
    Aaudi_Arabia.setText("saudi arabia");
    Aaudi_Arabia.addActionListener(new app_devise_Aaudi_Arabia_actionAdapter(this));
    jButton2.setText("jButton2");
    jPanel2.setLayout(gridBagLayout1);
    jLabel1.setText("1 GBP ");
    jLabel2.setText("1 USD ");
    jLabel3.setText("Bahreïn");
    jLabel4.setText("Émirats arabes unis       ");
    jLabel5.setText("United states");
    jLabel6.setText("united kingdom");
    jLabel10.setText("Qatar");
    jLabel11.setText("1 AED ");
    jLabel12.setText("1 CAD ");
    jLabel13.setText("Canada");
    jLabel14.setText("europe");
    jLabel15.setText("1 EUR ");
    jLabel16.setText("1 BHD ");
    jLabel17.setText("1 LYD ");
    jLabel18.setText("1 JPY ");
    jLabel19.setText("Japan");
    jLabel20.setText("libya");
    jLabel110.setText("Tunisia");
    jLabel7.setText("1 TND ");
    jLabel8.setText("1 QAR");
    jLabel9.setText(" = ");
    jLabel111.setText(" = ");
    jLabel21.setText(" = ");
    jLabel22.setText(" = ");
    jLabel23.setText(" = ");
    jLabel24.setText(" = ");
    jLabel25.setText(" = ");
    jLabel26.setText(" = ");
    jLabel27.setText(" = ");
    jLabel28.setText(" = ");
    TND.setText("TND");
    AED.setText("AED");
    USD.setText("USD ");
    CAD.setText("CAD");
    EUR.setText("EUR");
    GBP.setText("GBP");
    QAR.setText("QAR");
    JPY.setText("JPY");
    LYD.setText("LYD");
    BHD.setText("BHD");
    jPanel1.add(Aaudi_Arabia, null);
    jPanel1.add(jButton2, null);
    principale.add(jPanel2, BorderLayout.CENTER);
    jPanel2.add(jLabel4,                            new GridBagConstraints(0, 1, 3, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel5,                          new GridBagConstraints(0, 2, 2, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel3,                          new GridBagConstraints(0, 9, 4, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel6,                 new GridBagConstraints(0, 5, 2, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel10,                    new GridBagConstraints(0, 6, 2, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel11,            new GridBagConstraints(4, 1, 2, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel12,           new GridBagConstraints(4, 3, 2, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel13,           new GridBagConstraints(0, 3, 2, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel14,           new GridBagConstraints(0, 4, 2, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel15,           new GridBagConstraints(4, 4, 2, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel16,        new GridBagConstraints(4, 9, 2, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel17,       new GridBagConstraints(4, 8, 2, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel18,       new GridBagConstraints(4, 7, 2, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel19,       new GridBagConstraints(0, 7, 2, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel20,       new GridBagConstraints(0, 8, 2, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel110,       new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel2,                new GridBagConstraints(4, 2, 2, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel1,                    new GridBagConstraints(4, 5, 1, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel7,     new GridBagConstraints(4, 0, 2, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel8,     new GridBagConstraints(4, 6, 2, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel9,      new GridBagConstraints(6, 6, 1, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel111,      new GridBagConstraints(6, 5, 1, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel21,  new GridBagConstraints(6, 0, 1, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel22,  new GridBagConstraints(6, 1, 1, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel23,  new GridBagConstraints(6, 2, 1, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel24,  new GridBagConstraints(6, 3, 1, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel25,  new GridBagConstraints(6, 4, 1, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel26,  new GridBagConstraints(6, 7, 1, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel27,  new GridBagConstraints(6, 8, 1, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jLabel28,  new GridBagConstraints(6, 9, 1, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(TND,  new GridBagConstraints(7, 0, 1, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(AED,  new GridBagConstraints(7, 1, 1, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(USD,  new GridBagConstraints(7, 2, 1, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(CAD,  new GridBagConstraints(7, 3, 1, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(EUR,  new GridBagConstraints(7, 4, 1, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(GBP,  new GridBagConstraints(7, 5, 1, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(QAR,  new GridBagConstraints(7, 6, 1, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(JPY,  new GridBagConstraints(7, 7, 1, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(LYD,  new GridBagConstraints(7, 8, 1, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(BHD,  new GridBagConstraints(7, 9, 1, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    principale.add(jPanel1, BorderLayout.NORTH);
    this.add(principale, null);
    //this.sae();
    }
    Thread clockThread;
    // Démarrer l'applet
    public void start()
    {
      if (clockThread == null) {
                  clockThread = new Thread(this, "Clock");
                  clockThread.start();}
 
    }
 
    // Arrêter l'applet
    public void stop()
    {
    }
 
    // Détruire l'applet
    public void destroy()
    {
    }
 
    // Obtenir les informations d'applet
    public String getAppletInfo()
    {
        return "Information d'Applet";
    }
 
    // Obtenir les informations de paramètre
    public String[][] getParameterInfo()
    {
        return null;
    }
     public void getcode(String s1,JLabel jj)
     {
      URL google = null;
      String all=null;
      try {
        google = new URL(s1);
      } catch (MalformedURLException ex) {
      }
        URLConnection yc = null;
        try {
          yc = google.openConnection();
        } catch (IOException ex1) {
        }
        BufferedReader in = null;
        try {
          in = new BufferedReader(
              new InputStreamReader(
              yc.getInputStream()));
        } catch (IOException ex2) {
        }
         String inputLine;
 
        try {
          while ((inputLine = in.readLine()) != null) {
            all += inputLine;
          }
        } catch (IOException ex3) {
        }
        String aaaaa=all;
        //System.out.println(aaaaa.length());
       int a=aaaaa.indexOf("Calculated using an exchange rate of ")+35;int aa= aaaaa.indexOf("                    <span>correct on 2008-12-31</span>");
                         int aaa=aa-a;
                         String ss=aaaaa.substring(1090,1096);
                        jj.setText(ss+" SAR");
            try {
          in.close();
        } catch (IOException ex4) {
        }
 
     }
 
     // Méthode principale (main)
     public static void main(String[] args)
     {
         app_devise applet = new app_devise();
         applet.isStandalone = true;
         Frame frame;
         frame = new Frame();
         frame.setTitle("Cadre d'Applet");
         frame.add(applet, BorderLayout.CENTER);
         applet.init();
         applet.start();
         frame.setSize(400, 320);
         Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
         frame.setLocation((d.width - frame.getSize().width) / 2,
                           (d.height - frame.getSize().height) / 2);
         frame.setVisible(true);
     }
     public void sae(){
       try {
         this.getcode("http://finance.yahoo.com/currency/converter-pocket-guide/20081231/eur/sar",EUR);
    //     this.getcode("http://finance.yahoo.com/currency/converter-pocket-guide/20081231/aed/sar",AED);
      //   this.getcode("http://finance.yahoo.com/currency/converter-pocket-guide/20081231/usd/sar",USD);
   //      this.getcode("http://finance.yahoo.com/currency/converter-pocket-guide/20081231/CAD/sar",CAD);
     //    this.getcode("http://finance.yahoo.com/currency/converter-pocket-guide/20081231/GBP/sar",GBP);
       //  this.getcode("http://finance.yahoo.com/currency/converter-pocket-guide/20081231/QAR/sar",QAR);
        // this.getcode("http://finance.yahoo.com/currency/converter-pocket-guide/20081231/JPY/sar",JPY);
        // this.getcode("http://finance.yahoo.com/currency/converter-pocket-guide/20081231/LYD/sar",LYD);
        // this.getcode("http://finance.yahoo.com/currency/converter-pocket-guide/20081231/BHD/sar",BHD);
 
       } catch (Exception ex1) {
       }
 
 
     }
 
  void Aaudi_Arabia_actionPerformed(ActionEvent e) {
    // this.sae();
 
 
  }
 
 
  /**
   * run
   */
  public void run() {
    this.sae();
 
  }
 
 
}
 
class app_devise_Aaudi_Arabia_actionAdapter implements java.awt.event.ActionListener {
  app_devise adaptee;
 
  app_devise_Aaudi_Arabia_actionAdapter(app_devise adaptee) {
    this.adaptee = adaptee;
  }
  public void actionPerformed(ActionEvent e) {
    adaptee.Aaudi_Arabia_actionPerformed(e);
  }
}