26 package sun.applet;
27
28 import java.util.*;
29 import java.io.*;
30 import java.awt.*;
31 import java.awt.event.*;
32 import java.awt.print.*;
33 import javax.print.attribute.*;
34 import java.applet.*;
35 import java.net.URL;
36 import java.net.SocketPermission;
37 import java.security.AccessController;
38 import java.security.PrivilegedAction;
39 import sun.awt.SunToolkit;
40 import sun.awt.AppContext;
41
42 /**
43 * A frame to show the applet tag in.
44 */
45 @SuppressWarnings("serial") // JDK-implementation class
46 final class TextFrame extends Frame {
47
48 /**
49 * Create the tag frame.
50 */
51 @SuppressWarnings("deprecation")
52 TextFrame(int x, int y, String title, String text) {
53 setTitle(title);
54 TextArea txt = new TextArea(20, 60);
55 txt.setText(text);
56 txt.setEditable(false);
57
58 add("Center", txt);
59
60 Panel p = new Panel();
61 add("South", p);
62 Button b = new Button(amh.getMessage("button.dismiss", "Dismiss"));
63 p.add(b);
64
65 class ActionEventListener implements ActionListener {
74 move(x, y);
75 setVisible(true);
76
77 WindowListener windowEventListener = new WindowAdapter() {
78
79 @Override
80 public void windowClosing(WindowEvent evt) {
81 dispose();
82 }
83 };
84
85 addWindowListener(windowEventListener);
86 }
87 private static AppletMessageHandler amh = new AppletMessageHandler("textframe");
88
89 }
90
91 /**
92 * Lets us construct one using unix-style one shot behaviors.
93 */
94 final class StdAppletViewerFactory implements AppletViewerFactory {
95
96 @Override
97 public AppletViewer createAppletViewer(int x, int y,
98 URL doc, Hashtable<String, String> atts) {
99 return new AppletViewer(x, y, doc, atts, System.out, this);
100 }
101
102 @Override
103 public MenuBar getBaseMenuBar() {
104 return new MenuBar();
105 }
106
107 @Override
108 public boolean isStandalone() {
109 return true;
110 }
111 }
112
113 /**
114 * The applet viewer makes it possible to run a Java applet without using a browser.
115 * For details on the syntax that <B>appletviewer</B> supports, see
116 * <a href="../../../docs/tooldocs/appletviewertags.html">AppletViewer Tags</a>.
117 * (The document named appletviewertags.html in the JDK's docs/tooldocs directory,
118 * once the JDK docs have been installed.)
119 */
120 @SuppressWarnings({"serial", "deprecation"}) // JDK-implementation class
121 public class AppletViewer extends Frame implements AppletContext, Printable {
122
123 /**
124 * Some constants...
125 */
126 private static String defaultSaveFile = "Applet.ser";
127
128 /**
129 * The panel in which the applet is being displayed.
130 */
131 AppletViewerPanel panel;
132
133 /**
134 * The status line.
135 */
136 Label label;
137
138 /**
139 * output status messages to this stream
140 */
141
142 PrintStream statusMsgStream;
143
144 /**
145 * For cloning
146 */
147 AppletViewerFactory factory;
148
149
150 private final class UserActionListener implements ActionListener {
151 @Override
152 public void actionPerformed(ActionEvent evt) {
153 processUserAction(evt);
154 }
155 }
156
157 /**
158 * Create the applet viewer.
159 */
160 public AppletViewer(int x, int y, URL doc, Hashtable<String, String> atts,
161 PrintStream statusMsgStream, AppletViewerFactory factory) {
162 this.factory = factory;
163 this.statusMsgStream = statusMsgStream;
164 setTitle(amh.getMessage("tool.title", atts.get("code")));
165
166 MenuBar mb = factory.getBaseMenuBar();
167
168 Menu m = new Menu(amh.getMessage("menu.applet"));
169
202 setVisible(true);
203
204 WindowListener windowEventListener = new WindowAdapter() {
205
206 @Override
207 public void windowClosing(WindowEvent evt) {
208 appletClose();
209 }
210
211 @Override
212 public void windowIconified(WindowEvent evt) {
213 appletStop();
214 }
215
216 @Override
217 public void windowDeiconified(WindowEvent evt) {
218 appletStart();
219 }
220 };
221
222 class AppletEventListener implements AppletListener
223 {
224 final Frame frame;
225
226 public AppletEventListener(Frame frame)
227 {
228 this.frame = frame;
229 }
230
231 @Override
232 @SuppressWarnings("deprecation")
233 public void appletStateChanged(AppletEvent evt)
234 {
235 AppletPanel src = (AppletPanel)evt.getSource();
236
237 switch (evt.getID()) {
238 case AppletPanel.APPLET_RESIZE: {
239 if(src != null) {
240 resize(preferredSize());
241 validate();
|
26 package sun.applet;
27
28 import java.util.*;
29 import java.io.*;
30 import java.awt.*;
31 import java.awt.event.*;
32 import java.awt.print.*;
33 import javax.print.attribute.*;
34 import java.applet.*;
35 import java.net.URL;
36 import java.net.SocketPermission;
37 import java.security.AccessController;
38 import java.security.PrivilegedAction;
39 import sun.awt.SunToolkit;
40 import sun.awt.AppContext;
41
42 /**
43 * A frame to show the applet tag in.
44 */
45 @SuppressWarnings("serial") // JDK-implementation class
46 @Deprecated(since = "9")
47 final class TextFrame extends Frame {
48
49 /**
50 * Create the tag frame.
51 */
52 @SuppressWarnings("deprecation")
53 TextFrame(int x, int y, String title, String text) {
54 setTitle(title);
55 TextArea txt = new TextArea(20, 60);
56 txt.setText(text);
57 txt.setEditable(false);
58
59 add("Center", txt);
60
61 Panel p = new Panel();
62 add("South", p);
63 Button b = new Button(amh.getMessage("button.dismiss", "Dismiss"));
64 p.add(b);
65
66 class ActionEventListener implements ActionListener {
75 move(x, y);
76 setVisible(true);
77
78 WindowListener windowEventListener = new WindowAdapter() {
79
80 @Override
81 public void windowClosing(WindowEvent evt) {
82 dispose();
83 }
84 };
85
86 addWindowListener(windowEventListener);
87 }
88 private static AppletMessageHandler amh = new AppletMessageHandler("textframe");
89
90 }
91
92 /**
93 * Lets us construct one using unix-style one shot behaviors.
94 */
95 @Deprecated(since = "9")
96 final class StdAppletViewerFactory implements AppletViewerFactory {
97
98 @Override
99 public AppletViewer createAppletViewer(int x, int y,
100 URL doc, Hashtable<String, String> atts) {
101 return new AppletViewer(x, y, doc, atts, System.out, this);
102 }
103
104 @Override
105 public MenuBar getBaseMenuBar() {
106 return new MenuBar();
107 }
108
109 @Override
110 public boolean isStandalone() {
111 return true;
112 }
113 }
114
115 /**
116 * The applet viewer makes it possible to run a Java applet without using a browser.
117 * For details on the syntax that <B>appletviewer</B> supports, see
118 * <a href="../../../docs/tooldocs/appletviewertags.html">AppletViewer Tags</a>.
119 * (The document named appletviewertags.html in the JDK's docs/tooldocs directory,
120 * once the JDK docs have been installed.)
121 *
122 * @deprecated The Applet API is deprecated. See the
123 * <a href="../../java/applet/package-summary.html"> java.applet package
124 * documentation</a> for further information.
125 */
126 @SuppressWarnings({"serial"}) // JDK-implementation class
127 @Deprecated(since = "9")
128 public class AppletViewer extends Frame implements AppletContext, Printable {
129
130 /**
131 * Some constants...
132 */
133 private static String defaultSaveFile = "Applet.ser";
134
135 /**
136 * The panel in which the applet is being displayed.
137 */
138 AppletViewerPanel panel;
139
140 /**
141 * The status line.
142 */
143 Label label;
144
145 /**
146 * output status messages to this stream
147 */
148
149 PrintStream statusMsgStream;
150
151 /**
152 * For cloning
153 */
154 AppletViewerFactory factory;
155
156 @Deprecated(since = "9")
157 private final class UserActionListener implements ActionListener {
158 @Override
159 public void actionPerformed(ActionEvent evt) {
160 processUserAction(evt);
161 }
162 }
163
164 /**
165 * Create the applet viewer.
166 */
167 public AppletViewer(int x, int y, URL doc, Hashtable<String, String> atts,
168 PrintStream statusMsgStream, AppletViewerFactory factory) {
169 this.factory = factory;
170 this.statusMsgStream = statusMsgStream;
171 setTitle(amh.getMessage("tool.title", atts.get("code")));
172
173 MenuBar mb = factory.getBaseMenuBar();
174
175 Menu m = new Menu(amh.getMessage("menu.applet"));
176
209 setVisible(true);
210
211 WindowListener windowEventListener = new WindowAdapter() {
212
213 @Override
214 public void windowClosing(WindowEvent evt) {
215 appletClose();
216 }
217
218 @Override
219 public void windowIconified(WindowEvent evt) {
220 appletStop();
221 }
222
223 @Override
224 public void windowDeiconified(WindowEvent evt) {
225 appletStart();
226 }
227 };
228
229 @Deprecated(since = "9")
230 class AppletEventListener implements AppletListener
231 {
232 final Frame frame;
233
234 public AppletEventListener(Frame frame)
235 {
236 this.frame = frame;
237 }
238
239 @Override
240 @SuppressWarnings("deprecation")
241 public void appletStateChanged(AppletEvent evt)
242 {
243 AppletPanel src = (AppletPanel)evt.getSource();
244
245 switch (evt.getID()) {
246 case AppletPanel.APPLET_RESIZE: {
247 if(src != null) {
248 resize(preferredSize());
249 validate();
|