11.1 The basic applet



You inherit from class Applet and override the application methods.

paint() is called automatically when the applet decides that it needs to update itself.  When paint() is called, a handle to a Graphics object that represents the surface on which you can paint is passed into the method.

Case Study: Applet1.java

To run an applet, you must place it into a Web page and view the page inside a Java-enabled Web browser.



An applet has its life cycle like a thread does.

Applet3.java
 

init() Called when the applet is first created to perform first-time initialization of applet
start() Called every time the applet moves into sight on the Web browser to allow the applet to start
stop() Called every time the applet moves out of sight on the Web browser to allow the applet to shut off expensive operations.  Alse called before destory()
destory() Called when the applet is being unloaded from the page to perform final release of resources when the applet is no longer used


Next Page