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.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
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.MalformedURLException;
37 import java.net.SocketPermission;
38 import sun.misc.Ref;
39 import java.security.AccessController;
40 import java.security.PrivilegedAction;
41 import java.lang.reflect.InvocationTargetException;
42 import java.lang.reflect.Method;
43 import sun.awt.SunToolkit;
44 import sun.awt.AppContext;
45 import java.lang.ref.WeakReference;
46
47 /**
48 * A frame to show the applet tag in.
49 */
50 class TextFrame extends Frame {
51
52 /**
53 * Create the tag frame.
54 */
55 TextFrame(int x, int y, String title, String text) {
56 setTitle(title);
57 TextArea txt = new TextArea(20, 60);
58 txt.setText(text);
373 public AudioClip getAudioClip(URL url) {
374 checkConnect(url);
375 synchronized (audioClips) {
376 AudioClip clip = (AudioClip)audioClips.get(url);
377 if (clip == null) {
378 audioClips.put(url, clip = new AppletAudioClip(url));
379 }
380 return clip;
381 }
382 }
383
384 private static Map imageRefs = new HashMap();
385
386 /**
387 * Get an image.
388 */
389 public Image getImage(URL url) {
390 return getCachedImage(url);
391 }
392
393 static Image getCachedImage(URL url) {
394 // System.getSecurityManager().checkConnection(url.getHost(), url.getPort());
395 return (Image)getCachedImageRef(url).get();
396 }
397
398 /**
399 * Get an image ref.
400 */
401 static Ref getCachedImageRef(URL url) {
402 synchronized (imageRefs) {
403 AppletImageRef ref = (AppletImageRef)imageRefs.get(url);
404 if (ref == null) {
405 ref = new AppletImageRef(url);
406 imageRefs.put(url, ref);
407 }
408 return ref;
409 }
410 }
411
412 /**
413 * Flush the image cache.
414 */
415 static void flushImageCache() {
416 imageRefs.clear();
417 }
418
419 static Vector appletPanels = new Vector();
420
421 /**
422 * Get an applet by name.
423 */
424 public Applet getApplet(String name) {
425 AppletSecurity security = (AppletSecurity)System.getSecurityManager();
426 name = name.toLowerCase();
427 SocketPermission panelSp =
428 new SocketPermission(panel.getCodeBase().getHost(), "connect");
|
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.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
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.MalformedURLException;
37 import java.net.SocketPermission;
38 import java.security.AccessController;
39 import java.security.PrivilegedAction;
40 import java.lang.reflect.InvocationTargetException;
41 import java.lang.reflect.Method;
42 import sun.awt.SunToolkit;
43 import sun.awt.AppContext;
44 import java.lang.ref.WeakReference;
45
46 /**
47 * A frame to show the applet tag in.
48 */
49 class TextFrame extends Frame {
50
51 /**
52 * Create the tag frame.
53 */
54 TextFrame(int x, int y, String title, String text) {
55 setTitle(title);
56 TextArea txt = new TextArea(20, 60);
57 txt.setText(text);
372 public AudioClip getAudioClip(URL url) {
373 checkConnect(url);
374 synchronized (audioClips) {
375 AudioClip clip = (AudioClip)audioClips.get(url);
376 if (clip == null) {
377 audioClips.put(url, clip = new AppletAudioClip(url));
378 }
379 return clip;
380 }
381 }
382
383 private static Map imageRefs = new HashMap();
384
385 /**
386 * Get an image.
387 */
388 public Image getImage(URL url) {
389 return getCachedImage(url);
390 }
391
392 /**
393 * Get an image.
394 */
395 static Image getCachedImage(URL url) {
396 // System.getSecurityManager().checkConnection(url.getHost(), url.getPort());
397 synchronized (imageRefs) {
398 AppletImageRef ref = (AppletImageRef)imageRefs.get(url);
399 if (ref == null) {
400 ref = new AppletImageRef(url);
401 imageRefs.put(url, ref);
402 }
403 return ref.get();
404 }
405 }
406
407 /**
408 * Flush the image cache.
409 */
410 static void flushImageCache() {
411 imageRefs.clear();
412 }
413
414 static Vector appletPanels = new Vector();
415
416 /**
417 * Get an applet by name.
418 */
419 public Applet getApplet(String name) {
420 AppletSecurity security = (AppletSecurity)System.getSecurityManager();
421 name = name.toLowerCase();
422 SocketPermission panelSp =
423 new SocketPermission(panel.getCodeBase().getHost(), "connect");
|