Class AppletEnvironment

  • All Implemented Interfaces:
    java.applet.AppletContext, java.applet.AppletStub

    public class AppletEnvironment
    extends java.lang.Object
    implements java.applet.AppletContext, java.applet.AppletStub
    The applet environment including stub, context, and frame. The default environment puts the applet in a non-resizable frame; this can be changed by obtaining the frame and setting it resizable.
    Version:
    $Revision: 1.12 $
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.applet.Applet applet
      the applet
      private boolean appletStarted
      whether the applet has been started / displayed
      private java.awt.Container cont
      the applet container
      private boolean destroyed
      whether the applet has been destroyed
      private JNLPFile file
      the JNLP file
      private static Logger LOG  
      private java.util.Map<java.lang.String,​java.lang.String> parameters
      the parameters
      private WeakList<AppletAudioClip> weakClips
      weak references to the audio clips
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void appletResize​(int width, int height)  
      private void checkDestroyed()
      Checks whether the applet has been destroyed, and throws an IllegalStateException if the applet has been destroyed of.
      void destroy()
      Disposes the applet's resources and disables the applet environment from further use; after calling this method the applet stub and context methods throw IllegalStateExceptions.
      java.applet.Applet getApplet​(java.lang.String name)
      Returns the applet if the applet's name is specified, otherwise return null.
      java.applet.AppletContext getAppletContext()  
      java.awt.Container getAppletFrame()  
      java.util.Enumeration<java.applet.Applet> getApplets()
      Returns an enumeration that contains only the applet from the JNLP file.
      java.applet.AudioClip getAudioClip​(java.net.URL location)  
      java.net.URL getCodeBase()  
      java.net.URL getDocumentBase()  
      java.awt.Image getImage​(java.net.URL location)  
      java.lang.String getParameter​(java.lang.String name)  
      java.io.InputStream getStream​(java.lang.String key)
      Required for JRE1.4, but not implemented yet.
      java.util.Iterator<java.lang.String> getStreamKeys()
      Required for JRE1.4, but not implemented yet.
      boolean isActive()  
      void setApplet​(java.applet.Applet applet)
      Set the applet of this environment; can only be called once.
      void setStream​(java.lang.String key, java.io.InputStream stream)
      Required for JRE1.4, but not implemented yet.
      void showDocument​(java.net.URL uRL)  
      void showDocument​(java.net.URL uRL, java.lang.String str)
      Not implemented yet.
      void showStatus​(java.lang.String str)
      Not implemented yet.
      void startApplet()
      Initialize, start, and show the applet.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOG

        private static final Logger LOG
      • file

        private JNLPFile file
        the JNLP file
      • applet

        private java.applet.Applet applet
        the applet
      • parameters

        private java.util.Map<java.lang.String,​java.lang.String> parameters
        the parameters
      • cont

        private java.awt.Container cont
        the applet container
      • appletStarted

        private boolean appletStarted
        whether the applet has been started / displayed
      • destroyed

        private boolean destroyed
        whether the applet has been destroyed
    • Constructor Detail

      • AppletEnvironment

        public AppletEnvironment​(JNLPFile file,
                                 AppletInstance appletInstance,
                                 java.awt.Container cont)
        Create a new applet environment for the applet specified by the JNLP file.
        Parameters:
        file - jnlp file base to construct environment
        appletInstance - applet for this environment
        cont - container to place this applet to
      • AppletEnvironment

        public AppletEnvironment​(JNLPFile file,
                                 AppletInstance appletInstance)
        Create a new applet environment for the applet specified by the JNLP file, in a new frame.
        Parameters:
        file - jnlp file base to construct environment
        appletInstance - applet for this environment
    • Method Detail

      • checkDestroyed

        private void checkDestroyed()
        Checks whether the applet has been destroyed, and throws an IllegalStateException if the applet has been destroyed of.
        Throws:
        java.lang.IllegalStateException
      • destroy

        public void destroy()
        Disposes the applet's resources and disables the applet environment from further use; after calling this method the applet stub and context methods throw IllegalStateExceptions.
      • getAppletFrame

        public java.awt.Container getAppletFrame()
        Returns:
        the frame that contains the applet. Disposing this frame will destroy the applet.
      • startApplet

        public void startApplet()
        Initialize, start, and show the applet.
      • getApplet

        public java.applet.Applet getApplet​(java.lang.String name)
        Returns the applet if the applet's name is specified, otherwise return null.
        Specified by:
        getApplet in interface java.applet.AppletContext
      • setApplet

        public void setApplet​(java.applet.Applet applet)
        Set the applet of this environment; can only be called once.
        Parameters:
        applet - source of this environment
      • getApplets

        public java.util.Enumeration<java.applet.Applet> getApplets()
        Returns an enumeration that contains only the applet from the JNLP file.
        Specified by:
        getApplets in interface java.applet.AppletContext
      • getAudioClip

        public java.applet.AudioClip getAudioClip​(java.net.URL location)
        Specified by:
        getAudioClip in interface java.applet.AppletContext
        Parameters:
        location - source of clip
        Returns:
        an audio clip.
      • getImage

        public java.awt.Image getImage​(java.net.URL location)
        Specified by:
        getImage in interface java.applet.AppletContext
        Parameters:
        location - location of image
        Returns:
        an image loaded from the specified location.
      • showDocument

        public void showDocument​(java.net.URL uRL)
        Specified by:
        showDocument in interface java.applet.AppletContext
        Parameters:
        uRL - url of document
      • showDocument

        public void showDocument​(java.net.URL uRL,
                                 java.lang.String str)
        Not implemented yet.
        Specified by:
        showDocument in interface java.applet.AppletContext
        Parameters:
        uRL - source of document
        str - _self, _parent, _top, _blank or "name". Have sense only for applets. Not implemented for our javaws world
      • showStatus

        public void showStatus​(java.lang.String str)
        Not implemented yet.
        Specified by:
        showStatus in interface java.applet.AppletContext
        Parameters:
        str - id of applet
      • setStream

        public void setStream​(java.lang.String key,
                              java.io.InputStream stream)
        Required for JRE1.4, but not implemented yet.
        Specified by:
        setStream in interface java.applet.AppletContext
      • getStream

        public java.io.InputStream getStream​(java.lang.String key)
        Required for JRE1.4, but not implemented yet.
        Specified by:
        getStream in interface java.applet.AppletContext
      • getStreamKeys

        public java.util.Iterator<java.lang.String> getStreamKeys()
        Required for JRE1.4, but not implemented yet.
        Specified by:
        getStreamKeys in interface java.applet.AppletContext
      • appletResize

        public void appletResize​(int width,
                                 int height)
        Specified by:
        appletResize in interface java.applet.AppletStub
      • getAppletContext

        public java.applet.AppletContext getAppletContext()
        Specified by:
        getAppletContext in interface java.applet.AppletStub
      • getCodeBase

        public java.net.URL getCodeBase()
        Specified by:
        getCodeBase in interface java.applet.AppletStub
      • getDocumentBase

        public java.net.URL getDocumentBase()
        Specified by:
        getDocumentBase in interface java.applet.AppletStub
      • getParameter

        public java.lang.String getParameter​(java.lang.String name)
        Specified by:
        getParameter in interface java.applet.AppletStub
      • isActive

        public boolean isActive()
        Specified by:
        isActive in interface java.applet.AppletStub