2 * Copyright 1995-2005 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
30 import java.net.MalformedURLException;
35 * Sample applet panel class. The panel manages and manipulates the
36 * applet as it is being loaded. It forks a seperate thread in a new
37 * thread group to call the applet's init(), start(), stop(), and
40 * @author Arthur van Hoff
42 class AppletViewerPanel extends AppletPanel {
44 /* Are we debugging? */
45 static boolean debug = false;
58 * The attributes of the applet.
63 * JDK 1.1 serialVersionUID
65 private static final long serialVersionUID = 8890989370785545619L;
68 * Construct an applet viewer and start the applet.
70 AppletViewerPanel(URL documentURL, Hashtable atts) {
71 this.documentURL = documentURL;
74 String att = getParameter("codebase");
76 if (!att.endsWith("/")) {
80 baseURL = new URL(documentURL, att);
81 } catch (MalformedURLException e) {
84 if (baseURL == null) {
85 String file = documentURL.getFile();
86 int i = file.lastIndexOf('/');
87 if (i >= 0 && i < file.length() - 1) {
89 baseURL = new URL(documentURL, file.substring(0, i + 1));
90 } catch (MalformedURLException e) {
95 // when all is said & done, baseURL shouldn't be null
97 baseURL = documentURL;
103 * Get an applet parameter.
105 public String getParameter(String name) {
106 return (String)atts.get(name.toLowerCase());
110 * Get the document url.
112 public URL getDocumentBase() {
120 public URL getCodeBase() {
127 public int getWidth() {
128 String w = getParameter("width");
130 return Integer.valueOf(w).intValue();
139 public int getHeight() {
140 String h = getParameter("height");
142 return Integer.valueOf(h).intValue();
150 public boolean hasInitialFocus()
153 // 6234219: Do not set initial focus on an applet
154 // during startup if applet is targeted for
155 // JDK 1.1/1.2. [stanley.ho]
156 if (isJDK11Applet() || isJDK12Applet())
159 String initialFocus = getParameter("initial_focus");
161 if (initialFocus != null)
163 if (initialFocus.toLowerCase().equals("false"))
171 * Get the code parameter
173 public String getCode() {
174 return getParameter("code");
179 * Return the list of jar files if specified.
180 * Otherwise return null.
182 public String getJarFiles() {
183 return getParameter("archive");
187 * Return the value of the object param
189 public String getSerializedObject() {
190 return getParameter("object");// another name?
195 * Get the applet context. For now this is
196 * also implemented by the AppletPanel class.
198 public AppletContext getAppletContext() {
199 return (AppletContext)getParent();
202 static void debug(String s) {
204 System.err.println("AppletViewerPanel:::" + s);
207 static void debug(String s, Throwable t) {