< prev index next >

src/java.desktop/share/classes/java/applet/Applet.java

Print this page




  25 
  26 package java.applet;
  27 
  28 import java.awt.AWTPermission;
  29 import java.awt.Dimension;
  30 import java.awt.GraphicsEnvironment;
  31 import java.awt.HeadlessException;
  32 import java.awt.Image;
  33 import java.awt.Panel;
  34 import java.io.IOException;
  35 import java.io.ObjectInputStream;
  36 import java.net.MalformedURLException;
  37 import java.net.URL;
  38 import java.util.Locale;
  39 
  40 import javax.accessibility.AccessibleContext;
  41 import javax.accessibility.AccessibleRole;
  42 import javax.accessibility.AccessibleState;
  43 import javax.accessibility.AccessibleStateSet;
  44 


  45 /**
  46  * An applet is a small program that is intended not to be run on
  47  * its own, but rather to be embedded inside another application.
  48  * <p>
  49  * The {@code Applet} class must be the superclass of any
  50  * applet that is to be embedded in a Web page or viewed by the Java
  51  * Applet Viewer. The {@code Applet} class provides a standard
  52  * interface between applets and their environment.
  53  *
  54  * @author      Arthur van Hoff
  55  * @author      Chris Warth
  56  * @since       1.0
  57  *
  58  * @deprecated The Applet API is deprecated, no replacement.
  59  */
  60 @Deprecated(since = "9")
  61 public class Applet extends Panel {
  62 
  63     /**
  64      * Constructs a new Applet.


 305      * @return  the image at the specified URL.
 306      * @see     java.awt.Image
 307      */
 308     public Image getImage(URL url, String name) {
 309         try {
 310             return getImage(new URL(url, name));
 311         } catch (MalformedURLException e) {
 312             return null;
 313         }
 314     }
 315 
 316     /**
 317      * Get an audio clip from the given URL.
 318      *
 319      * @param url points to the audio clip
 320      * @return the audio clip at the specified URL.
 321      *
 322      * @since       1.2
 323      */
 324     public static final AudioClip newAudioClip(URL url) {
 325         return new sun.applet.AppletAudioClip(url);
 326     }
 327 
 328     /**
 329      * Returns the {@code AudioClip} object specified by the
 330      * {@code URL} argument.
 331      * <p>
 332      * This method always returns immediately, whether or not the audio
 333      * clip exists. When this applet attempts to play the audio clip, the
 334      * data will be loaded.
 335      *
 336      * @param   url  an absolute URL giving the location of the audio clip.
 337      * @return  the audio clip at the specified URL.
 338      * @see     java.applet.AudioClip
 339      */
 340     public AudioClip getAudioClip(URL url) {
 341         return getAppletContext().getAudioClip(url);
 342     }
 343 
 344     /**
 345      * Returns the {@code AudioClip} object specified by the




  25 
  26 package java.applet;
  27 
  28 import java.awt.AWTPermission;
  29 import java.awt.Dimension;
  30 import java.awt.GraphicsEnvironment;
  31 import java.awt.HeadlessException;
  32 import java.awt.Image;
  33 import java.awt.Panel;
  34 import java.io.IOException;
  35 import java.io.ObjectInputStream;
  36 import java.net.MalformedURLException;
  37 import java.net.URL;
  38 import java.util.Locale;
  39 
  40 import javax.accessibility.AccessibleContext;
  41 import javax.accessibility.AccessibleRole;
  42 import javax.accessibility.AccessibleState;
  43 import javax.accessibility.AccessibleStateSet;
  44 
  45 import com.sun.media.sound.JavaSoundAudioClip;
  46 
  47 /**
  48  * An applet is a small program that is intended not to be run on
  49  * its own, but rather to be embedded inside another application.
  50  * <p>
  51  * The {@code Applet} class must be the superclass of any
  52  * applet that is to be embedded in a Web page or viewed by the Java
  53  * Applet Viewer. The {@code Applet} class provides a standard
  54  * interface between applets and their environment.
  55  *
  56  * @author      Arthur van Hoff
  57  * @author      Chris Warth
  58  * @since       1.0
  59  *
  60  * @deprecated The Applet API is deprecated, no replacement.
  61  */
  62 @Deprecated(since = "9")
  63 public class Applet extends Panel {
  64 
  65     /**
  66      * Constructs a new Applet.


 307      * @return  the image at the specified URL.
 308      * @see     java.awt.Image
 309      */
 310     public Image getImage(URL url, String name) {
 311         try {
 312             return getImage(new URL(url, name));
 313         } catch (MalformedURLException e) {
 314             return null;
 315         }
 316     }
 317 
 318     /**
 319      * Get an audio clip from the given URL.
 320      *
 321      * @param url points to the audio clip
 322      * @return the audio clip at the specified URL.
 323      *
 324      * @since       1.2
 325      */
 326     public static final AudioClip newAudioClip(URL url) {
 327         return JavaSoundAudioClip.create(url);
 328     }
 329 
 330     /**
 331      * Returns the {@code AudioClip} object specified by the
 332      * {@code URL} argument.
 333      * <p>
 334      * This method always returns immediately, whether or not the audio
 335      * clip exists. When this applet attempts to play the audio clip, the
 336      * data will be loaded.
 337      *
 338      * @param   url  an absolute URL giving the location of the audio clip.
 339      * @return  the audio clip at the specified URL.
 340      * @see     java.applet.AudioClip
 341      */
 342     public AudioClip getAudioClip(URL url) {
 343         return getAppletContext().getAudioClip(url);
 344     }
 345 
 346     /**
 347      * Returns the {@code AudioClip} object specified by the


< prev index next >