|
Do you expect that applets will have a main method? A good answer might be:No. An applet is an object who's methods are called by the browser. | |
An Example AppletWhen you define an applet, you are defining an object that will be used by another program, the web browser. The web browser is the application program and (at least conceptually) has the main() method. The applet object web provides services (methods) to the browser when the browser asks for them. An applet object has many variables and methods. Most of this comes along automatically when you use the definition of Applet from the JDK. You get this definition when you import java.applet.Applet. Almost always, you will also import java.awt.*. This contains many classes that are useful for windows and graphics. Here is the code for a small applet. The name of the class is AEHouseman.
This applet must be compiled into bytecode (just like an application.) Then it can be used in a web page. Here is what this applet does: This applet will be explained in the next several pages. | |
QUESTION 2:
Look at the Click Here after you have answered the questionpublic void paint ( Graphics gr ) |