Monday, August 10, 2009

Adding Java applet to HTML

There is an <APPLET> tag that specifies the location of the class file and the display area allocated to the applet. Suppose you want to add a clock applet that will display the current time in hours, minutes, and seconds. Suppose we have a compiled clock applet called Clock.class. A simple example of an <APPLET> tag that loads the Clock applet:

< APPLET = "Clock.class" width="200" height="60">< / A P P L E T >

When a browser encounters these tagsm it will start the VM and ask it to load Clock.class. It also tells the VM that the applet may draw in a region that is 200 x 60 pixels. The location of the <APPLET> tag in the document determines the coordinate of the top left of the applet's display area.

< html>

< head>

< title> Sample HTML Document< /title>

< /head>

< body>

< img src="Twinkle.gif" />

< h1>HTML Demo</ h1>

This document is a sample of HTML.

< p>

Share your expertise< a href=">http://groups.google.com/group/nanonagle-tech">Join Techno Talk Group< /a>

<P>

< APPLET = "Clock.class" width="200" height="60">< / A P P L E T >

</ body>

</ html>

As you can see, embedding applets into Web pages is simple. Java is able to create plug-in components that can be used by novices as well as experts. For this component strategy to work, the HTML author must be able to customize the properties and behaviour of the applet via HTML. The Java programmer decides which parameters will have meaning for the applet, and the HTML author uses <PARAM> tags to pass initial parameters to the applet. The clock applet needs no parameters, telling the time is a universal function.

No comments:

Post a Comment

Search Techno Talk

Google Groups
Subscribe to Techno Talk
Email:
Visit this group