Applet 是一個小程序,它不能獨(dú)立運(yùn)行,但是可以嵌入到另一個應(yīng)用中。
Applet
類必定是嵌入Web 頁面或通過 Applet 瀏覽器瀏覽的 applet 的父類。
Applet
類在 applet 和它們的環(huán)境之間提供了一個標(biāo)準(zhǔn)的接口。
java.lang.Object | +----java.awt.Component | +----java.awt.Container | +----java.awt.Panel | +----java.applet.Applet
URL
參數(shù)指定的 AudioClip
對象。
URL
和 name
參數(shù)指定的
AudioClip
對象。
Image
對象。
Image
對象。
public Applet()
public final void setStub(AppletStub stub)
public boolean isActive()
start
方法被調(diào)用之前,它就被標(biāo)記為活動。 在 applet 的 stop
方法被調(diào)用之后,它立刻成為非活動的。
public URL getDocumentBase()
URL
是包含該 applet 文檔的 URL 。
public URL getCodeBase()
URL
是這個 applet 的 URL 。
public String getParameter(String name)
<applet code="Clock" width=50 height=50>
<param name=Color value="blue">
</applet>
那么調(diào)用 getParameter("Color")
的返回值為 "blue"
.
name
參數(shù)不區(qū)分大小寫。
public AppletContext getAppletContext()
applet 的環(huán)境在包含該 applet 的文檔中描述。
public void resize(int width, int height)
public void resize(Dimension d)showStatus
public void showStatus(String msg)
public Image getImage(URL url)
Image
對象。 作為參數(shù)傳送的 url
必須指定出絕對的 URL 。
不論映像是否存在,這個方法總是立刻返回。當(dāng)該 applet 試圖在屏幕上繪制映像時(shí),數(shù)據(jù)將被裝入。 繪制映像的圖形原語將逐漸繪制到屏幕上。
public Image getImage(URL url, String name)
Image
對象。
url
參數(shù)必須指明一個絕對 URL 。 name
參數(shù)是一個相對的 url
參數(shù)描述。
不論映像是否存在,這個方法總是立刻返回。當(dāng)該 applet 試圖在屏幕上繪制映像時(shí),數(shù)據(jù)將被裝入。 繪制映像的圖形原語將逐漸繪制到屏幕上。
url
參數(shù)。
public AudioClip getAudioClip(URL url)
AudioClip
對象,由 URL
參數(shù)指定。
不論音頻剪輯是否存在,這個方法總是立刻返回。 當(dāng)該 applet 試圖播放音頻剪輯時(shí),數(shù)據(jù)將被裝入。
public AudioClip getAudioClip(URL url, String name)
AudioClip
對象,由 URL
和
name
參數(shù)指定。
不論音頻剪輯是否存在,這個方法總是立刻返回。 當(dāng)該 applet 試圖播放音頻剪輯時(shí),數(shù)據(jù)將被裝入。
url
參數(shù)。
public String getAppletInfo()
String
執(zhí)行這個由 Applet
類提供的方法,將返回
null
。
public Locale getLocale()
public String[][] getParameterInfo()
Strings
數(shù)組來描述這些參數(shù)。
數(shù)組的每個元素都應(yīng)當(dāng)是一個有三個 Strings
的集合,包括名稱,類型,和一個說明。例如:
String pinfo[][] = { {"fps", "1-10", "frames per second"}, {"repeat", "boolean", "repeat image loop"}, {"imgs", "url", "images directory"} };
執(zhí)行這個由 Applet
類提供的方法,將返回
null
。
public void play(URL url)
public void play(URL url, String name)
url
參數(shù)。
public void init()
start
方法之前被調(diào)用。
如果它有初始化方法來執(zhí)行, Applet
的子類應(yīng)當(dāng)覆蓋這個方法。 例如,有線程的 applet 要使用 init
方法來創(chuàng)建線程,并用 destroy
方法來終止它們。
執(zhí)行這個由 Applet
類提供的方法什么都不做。
public void start()
init
方法后和每次在 Web 頁面上的 applet 被重新訪問后,它被調(diào)用。
Applet
的子類應(yīng)當(dāng)覆蓋這個方法,如果在每次包含它的 Web 頁面被訪問時(shí)有任何操作要執(zhí)行。 例如,帶有動畫的 applet 要使用 start
方法來執(zhí)行動畫,并且要使用 stop
方法來停止動畫。
執(zhí)行這個由 Applet
類提供的方法什么都不做。
public void stop()
Applet
的子類應(yīng)當(dāng)覆蓋這個方法,如果在每次包含它的 Web 頁面不再可見時(shí)有任何操作要執(zhí)行。 例如,帶有動畫的 applet 要使用 start
方法來執(zhí)行動畫,并且要使用 stop
方法來停止動畫。
執(zhí)行這個由 Applet
類提供的方法什么都不做。
public void destroy()
stop
方法總在
destroy
之前被調(diào)用。
Applet
的子類應(yīng)當(dāng)覆蓋這個方法,如果在它被撤消前有任何操作要執(zhí)行。 例如,有線程的 applet 要使用 init
方法來創(chuàng)建線程,并用 destroy
方法來終止它們。
Applet
類提供的方法的實(shí)現(xiàn)什么都不做。