看板 ott
作者 ott(寶貝)
標題 The java.applet Package      
時間 2010年01月13日 Wed. PM 05:17:39




      The java.applet Package
     
     The java.applet package is a small but important package that
     defines the Applet class--the superclass of all applets. It also
     defines the AppletContext and AppletStub interfaces, which are
     implemented by web browsers and other applet viewers. Finally, for
     lack of a better place, this package contains the AudioClip
     interface, which represents a sound to be played. Figure 8-1 shows
     the class hierarchy of this package. See Chapter 7, "Applets", for
     more details about applets.
     

     
[圖]

     
     Figure 8-1. The java.applet package
     
     Applet
	
Java 1.0
     
     java.applet
	
serializable AWT component PJ1.1
     This class implements an applet. To create your own applet, you
     should create a subclass of this class and override some or all of
     the following methods. Note that you never need to call these
     methods--they are called when appropriate by a web browser or
     other applet viewer.
     
     init() should perform any initialization for the applet; it is
     called when the applet first starts. destroy() should free up any
     resources that the applet is holding; it is called when the applet
     is about to be permanently stopped. start() is called to make
     applet start doing whatever it is that it does. Often, it starts a
     thread to perform an animation or similar task. stop() should
     temporarily stop the applet from executing. It is called when the
     applet temporarily becomes hidden or nonvisible.
     
     getAppletInfo() should return text suitable for display in an
     About dialog posted by the web browser or applet viewer.
     getParameterInfo() should return an arbitrary-length array of
     three-element arrays of strings, where each element describes one
     of the parameters that this applet understands. The three elements
     of each parameter description are strings that specify the
     parameter's name, type, and description, respectively.
     
     In addition to these methods, an applet typically overrides
     several of the methods of java.awt.Component, notably the paint()
     method to draw the applet on the screen.
     
     There are also several Applet methods that you do not override but
     may call from applet code: showStatus() displays text in the web
     browser or applet viewer's status line. getImage() and
     getAudioClip() read image (GIF and JPEG formats) and audio files
     (AU format) over the network and return corresponding Java
     objects. getParameter() looks up the value of a parameter
     specified with a <PARAM> tag within an <APPLET>/</APPLET> pair.
     getCodeBase() returns the base URL from which the applet's code
     was loaded, while getDocumentBase() returns the base URL from
     which the HTML document containing the applet was loaded. Finally,
     getAppletContext() returns an AppletContext object.
     
     public class Applet extends java.awt.Panel {
     //
	
Public Constructors
     public Applet ();
	

     //
	
Public Class Methods
     1.2
	
public static final AudioClip newAudioClip (java.net.URL
     url);
	

     //
	
Property Accessor Methods (by property name)
     public boolean isActive ();
	
 default:false
     public AppletContext getAppletContext ();
	

     public String getAppletInfo ();
	
 constant default:null
     public java.net.URL getCodeBase ();
	

     public java.net.URL getDocumentBase ();
	

     1.1
	
public java.util.Locale getLocale ();
	

     Overrides:Component
     public String[ ][ ] getParameterInfo ();
	
 constant
     default:null
     //
	
Public Instance Methods
     public void destroy ();
	
 empty
     public AudioClip getAudioClip (java.net.URL url);
	

     public AudioClip getAudioClip (java.net.URL url, String name);
	

     public java.awt.Image getImage (java.net.URL url);
	

     public java.awt.Image getImage (java.net.URL url, String name);
	

     public String getParameter (String name);
	

     public void init ();
	
 empty
     public void play (java.net.URL url);
	

     public void play (java.net.URL url, String name);
	

     public final void setStub (AppletStub stub);
	

     public void showStatus (String msg);
	

     public void start ();
	
 empty
     public void stop ();
	
 empty
     //
	
Public Methods Overriding Component
     public void resize (java.awt.Dimension d);
	

     public void resize (int width, int height);
	

     }
     Hierarchy:
     Object-->Component(java.awt.image.ImageObserver,java.awt.MenuConta
     iner,Serializable)-->Container-->java.awt.Panel-->Applet
     
     Subclasses: javax.swing.JApplet
     
     Passed To: java.beans.AppletInitializer.{activate(),
     initialize()}, org.omg.CORBA.ORB.{init(), set_parameters()}
     
     Returned By: AppletContext.getApplet()
     
     AppletContext
	
Java 1.0
     
     java.applet
	
PJ1.1
     This interface defines the methods that allow an applet to
     interact with the context in which it runs (usually a web browser
     or an applet viewer). The getAppletContext() method of Applet
     returns an object that implements the AppletContext interface. You
     can use an AppletContext to take advantage of a web browser's
     cache or display a message to the user in the web browser or
     applet viewer's message area. The getAudioClip() and getImage()
     methods may make use of a web browser's caching mechanism.
     showDocument() and showStatus() give an applet a small measure of
     control over the appearance of the browser or applet viewer. The
     getApplet() and getApplets() methods allow an applet to find out
     what other applets are running at the same time.
     
     public abstract interface AppletContext {
     //
	
Public Instance Methods
     public abstract Applet getApplet (String name);
	

     public abstract java.util.Enumeration getApplets ();
	

     public abstract AudioClip getAudioClip (java.net.URL url);
	

     public abstract java.awt.Image getImage (java.net.URL url);
	

     public abstract void showDocument (java.net.URL url);
	

     public abstract void showDocument (java.net.URL url, String
     target);
	

     public abstract void showStatus (String status);
	

     }
     Returned By: Applet.getAppletContext(),
     AppletStub.getAppletContext()
     
     AppletStub
	
Java 1.0
     
     java.applet
	
PJ1.1
     This is an internal interface used when implementing an applet
     viewer.
     
     public abstract interface AppletStub {
     //
	
Property Accessor Methods (by property name)
     public abstract boolean isActive ();
	

     public abstract AppletContext getAppletContext ();
	

     public abstract java.net.URL getCodeBase ();
	

     public abstract java.net.URL getDocumentBase ();
	

     //
	
Public Instance Methods
     public abstract void appletResize (int width, int height);
	

     public abstract String getParameter (String name);
	

     }
     Passed To: Applet.setStub()
     
     AudioClip
	
Java 1.0
     
     java.applet
	
PJ1.1

     This interface describes the essential methods that an audio clip
     must have. The getAudioClip() methods of Applet and AppletContext
     both return an object that implements this interface. The current
     Java SDK implementation of this interface works only with sounds
     encoded in AU format. The AudioClip interface is in the
     java.applet package only because there is no better place for it.
     
     public abstract interface AudioClip {
     //
	
Public Instance Methods
     public abstract void loop ();
	

     public abstract void play ();
	

     public abstract void stop ();
	

     }


     Returned By: Applet.{getAudioClip(), newAudioClip()},
      AppletContext.getAudioClip()

--
※ 來源: DISP BBS (http://disp.twbbs.org)
※ 作者: ott  來自: 118.166.4.170  時間: 2010-01-13 17:17:39
※ 看板: ott 文章推薦值: 0 目前人氣: 0 累積人氣: 102 
※ 文章分類: -computer
分享網址: 複製 已複製
guest
x)推文 r)回覆 e)編輯 d)刪除 M)收藏 ^x)轉錄 同主題: =)首篇 [)上篇 ])下篇