An applet is a small program that is intended not to be run on its own, but rather to be embedded inside another application. The Applet class must be the superclass of any applet that is to be embedded in a Web page or viewed by the Java Applet Viewer. The Applet class provides a standard interface between applets and their environment. The Applet class doesn't provide any genuine applicability on its own. Its purpose is to provide a super class from which custom applet classes are extended
Method
|
Description
|
destroy() public void destroy() |
Cleans up whatever resources are being held. |
getAppletContext()
public AppletContext getAppletContext() |
Gets a handle to the applet context. Gets a handle to the applet context. The applet context lets an applet control the applet's environment which is usually the browser or the applet viewer. |
getAppletInfo()
public String getAppletInfo() |
Return a string containing information about the author, version and copyright of the applet. |
getAudioClip(URL) public AudioClip getAudioClip(URL url) |
Gets an audio clip. |
getCodeBase()
public URL getCodeBase() |
Gets the base URL. |
getDocumentBase()
public URL getDocumentBase() |
Gets the document URL. |
getImage(URL)
public Image getImage(URL url, String name) |
Gets an image given a URL. |
getImage(URL, String)
public Image getImage(URL url, String name) |
Gets an image relative to a URL. |
getParameter(String)
public String getParameter(String name) |
Gets a parameter of the applet. |
getParameterInfo()
public String[][] getParameterInfo() |
Returns an array of strings describing the parameters that are understoond by this applet. |
init()
public void init() |
Initializes the applet. |
isActive()
public boolean isActive() |
Returns true if the applet is active. |
play(URL)
public void play(URL url,String name) |
Play an audio clip. |
play(URL, String)
public void play(URL url) |
Play an audio clip. |
resize(int, int)
public void resize(int width,int height) |
Request for the applet to be resized. |
public final void setStub(AppletStub stub) |
Set the applet stub. |
stop()
public void stop() |
Called to stop the applet. |
public void showStatus(String msg) |
Show a status message in the Applet's context. |
start()
public void start() |
Called to start the applet. |
The Java class library provides the Applet class with default implementation for all the applet methods. You can implement these methods in the applet class when you want to override the default implementation of these methods. In your example, you are extending the applet1 class to Applet class, therefore the methods are already implemented.By defining the init(), start() and paint() method,you are overriding the applet methods. Therefore if you will haven't define the init() or start() methods, the paint() method can still be invoked.
0 comments:
Post a Comment