1   /**
2    * Copyright (c) 2000-2007 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.lawt;
24  
25  import java.applet.Applet;
26  import java.applet.AppletContext;
27  import java.applet.AppletStub;
28  import java.applet.AudioClip;
29  
30  import java.awt.Frame;
31  import java.awt.Image;
32  import java.awt.event.WindowAdapter;
33  import java.awt.event.WindowEvent;
34  
35  import java.io.InputStream;
36  
37  import java.net.URL;
38  
39  import java.util.Enumeration;
40  import java.util.HashMap;
41  import java.util.Iterator;
42  import java.util.Map;
43  
44  /**
45   * <a href="AppletFrame.java.html"><b><i>View Source</i></b></a>
46   *
47   * @author Brian Wing Shun Chan
48   *
49   */
50  public class AppletFrame extends Frame implements AppletStub, AppletContext {
51  
52      public AppletFrame(Applet applet, int x, int y) {
53          this(applet, new HashMap(), x, y);
54      }
55  
56      public AppletFrame(Applet applet, Map params, int x, int y) {
57          setTitle(applet.getClass().getName());
58          setSize(x, y);
59  
60          _params = params;
61  
62          addWindowListener(
63              new WindowAdapter() {
64                  public void windowClosing(WindowEvent e) {
65                      System.exit(0);
66                  }
67              }
68          );
69  
70          add(applet);
71          applet.setStub(this);
72          applet.init();
73          show();
74          applet.start();
75      }
76  
77      // AppletStub methods
78  
79      public void appletResize(int width, int height) {
80      }
81  
82      public AppletContext getAppletContext() {
83          return this;
84      }
85  
86      public URL getCodeBase() {
87          return null;
88      }
89  
90      public URL getDocumentBase() {
91          return null;
92      }
93  
94      public String getParameter(String name) {
95          return (String)_params.get(name);
96      }
97  
98      public boolean isActive() {
99          return true;
100     }
101 
102     // AppletContext methods
103 
104     public Applet getApplet(String name) {
105         return null;
106     }
107 
108     public Enumeration getApplets() {
109         return null;
110     }
111 
112     public AudioClip getAudioClip(URL url) {
113         return null;
114     }
115 
116     public Image getImage(URL url) {
117         return null;
118     }
119 
120     public InputStream getStream(String key) {
121         return null;
122     }
123 
124     public Iterator getStreamKeys() {
125         return null;
126     }
127 
128     public void setStream(String key, InputStream stream) {
129     }
130 
131     public void showDocument(URL url) {
132     }
133 
134     public void showDocument(URL url, String target) {
135     }
136 
137     public void showStatus(String status) {
138     }
139 
140     private Map _params;
141 
142 }