1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 import java.awt.Graphics; 23 import java.awt.Color; 24 import java.io.File; 25 import java.io.IOException; 26 import java.net.URL; 27 import java.io.InputStream; 28 import java.net.MalformedURLException; 29 /* 30 * TestApplet.java 31 * 32 * Created on 21. November 2001, 09:37 33 */ 34 35 /** 36 * 37 * @author jl97489 38 * @version 39 */ 40 public class TestApplet extends java.applet.Applet { 41 42 /** Initialization method that will be called after the applet is loaded 43 * into the browser. 44 */ init()45 public void init () { 46 setBackground( Color.green); 47 resize( 300, 300); 48 49 // Security tests. 50 File f= new File("d:\\temp\\javasecurity.txt"); 51 SecurityManager mgr= System.getSecurityManager(); 52 try { 53 f.createNewFile(); 54 55 // local connection 56 URL url= new URL("http://localhost:8080/index.html"); 57 InputStream is= url.openStream(); 58 // remote connection 59 url= new URL("http://www.w3.org/index.html"); 60 is= url.openStream(); 61 }catch( MalformedURLException mue) { 62 }catch( IOException e) { 63 String s= e.getMessage(); 64 System.out.println(s); 65 }catch( SandboxSecurityException sse) { 66 String s= sse.getMessage(); 67 System.out.println("s"); 68 } 69 // catch( Exception ex) { 70 // String s= ex.getMessage(); 71 // ex.printStackTrace(); 72 // } 73 74 } 75 paint( Graphics g)76 public void paint( Graphics g) { 77 super.paint( g); 78 } 79 } 80