1 import java.awt.Graphics;
2 import java.awt.Color;
3 import java.io.File;
4 import java.io.IOException;
5 import java.net.URL;
6 import java.io.InputStream;
7 import java.net.MalformedURLException;
8 /*
9  * TestApplet.java
10  *
11  * Created on 21. November 2001, 09:37
12  */
13 
14 /**
15  *
16  * @author  jl97489
17  * @version
18  */
19 public class TestApplet extends java.applet.Applet {
20 
21     /** Initialization method that will be called after the applet is loaded
22      *  into the browser.
23      */
24     public void init () {
25         setBackground( Color.green);
26         resize( 300, 300);
27 
28         // Security tests.
29         File f= new File("d:\\temp\\javasecurity.txt");
30         SecurityManager mgr= System.getSecurityManager();
31         try {
32             f.createNewFile();
33 
34         // local connection
35         URL url= new URL("http://localhost:8080/index.html");
36         InputStream is= url.openStream();
37         // remote connection
38         url= new URL("http://www.w3.org/index.html");
39         is= url.openStream();
40         }catch( MalformedURLException mue) {
41         }catch( IOException e) {
42             String s= e.getMessage();
43             System.out.println(s);
44         }catch( SandboxSecurityException sse) {
45             String s= sse.getMessage();
46             System.out.println("s");
47         }
48         //        catch( Exception ex) {
49 //            String s= ex.getMessage();
50 //            ex.printStackTrace();
51 //        }
52 
53     }
54 
55     public void paint( Graphics g) {
56         super.paint( g);
57     }
58 }
59