01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.harmony.tools.appletviewer;
19:
20: import java.applet.AppletContext;
21: import java.applet.AppletStub;
22: import java.awt.Component;
23: import java.awt.Dimension;
24: import java.awt.Window;
25: import java.net.URL;
26:
27: class ViewerAppletStub implements AppletStub {
28: private final Component appletPane;
29: private final AppletInfo appletInfo;
30: private final AppletContext appletContext;
31:
32: ViewerAppletStub(Component appletPane, AppletInfo appletInfo) {
33: this .appletPane = appletPane;
34: this .appletInfo = appletInfo;
35: this .appletContext = new ViewerAppletContext(appletInfo);
36: }
37:
38: public boolean isActive() {
39: return false;
40: }
41:
42: public URL getDocumentBase() {
43: return appletInfo.getDocumentBase();
44: }
45:
46: public URL getCodeBase() {
47: return appletInfo.getCodeBase();
48: }
49:
50: public String getParameter(String name) {
51: return appletInfo.getParameter(name);
52: }
53:
54: public AppletContext getAppletContext() {
55: return appletContext;
56: }
57:
58: public void appletResize(int width, int height) {
59: Component cmp = appletPane;
60:
61: appletPane.setPreferredSize(new Dimension(width, height));
62:
63: while (cmp != null) {
64: cmp = cmp.getParent();
65:
66: if (cmp instanceof Window) {
67: ((Window) cmp).pack();
68: break;
69: }
70: }
71: }
72: }
|