JAVA-MANI.BLOGSPOT.COM
Tuesday, June 24, 2008
A Java applet produces object code which can be interpreted within the user's browser. This means that naive users do not have to fuss with program installation. Applets also provide security by restricting local user resource access. Applets can be useful, user friendly programs

Here is the explanation of the basic structure of a Java applet using the one that you wrote to test your working environment. Applets are placed in XHTML documents and are executed from within a Java aware browser.

Line three uses the reserved word import which indicates that objects from external libraries awt and applet are going to be used. Line four uses the reserved word extends to indicate that the class being created is a subclass of the Applet class. This demonstrates how Java code is reused and extended.
Note: The JApplet class is used instead of Applet whenever Swing GUI is used.

Line six starts the override (change) of the java.applet.Applet class init() method. Line eleven invokes the resize() method of the Applet object and sets the window dimensions. Note the all important statement ending semicolon.

Line 12 is another method override declaration. This time it is the paint() method of the Applet object. It is being passed an object of the Graphics class called g. Line 14 tells the Graphics object g to invoke its method drawString() using the string "Hello World! and position it at point (50,25) in the previously assigned window. A later tutorial gives details on graphics programming within applets.


0 comments:

SUBSCRIBE VIA eMAIL

Enter your email address:

Delivered by FeedBurner

Recent Posts

Firefox 3

Counter

internet companies

Live Traffic Map

Subscribe Now