advertisement
javaboutique
Search Tips
Articles  |   Tutorials  |   Reviews  |   Tools  |   by Category  |   by Date  |   by Name  |   Submit  |   Source  |   Forums  |  
javaboutique
Browse DevX


Partners & Affiliates











advertisement

Articles : Tutorials : DragonClock Applet and Tutorial :

Adding the Applet to Your Webpage

Contents
Introduction
Object Oriented Programming and Java
Setting Up an Applet
Applet Methods
Other Required Methods
Adding the Applet to Your Webpage

We now have a completed Java applet. We have compiled it into bytecodes so that it will run independent of platform. However, all this will do us no good if we do not attach the applet to a webpage.

The APPLET Tag

The first tag to add to your page is APPLET. After defining the applet, you declare any parameter you wish to pass to the applet. We will look at the PARAM tag next.

The attributes of the APPLET tag are:

ALIGN=value
Values can be LEFT, RIGHT, TOP, MIDDLE, or BOTTOM. ALIGN defines the horizontal alignment of the applet.
ALT="message"
If the applet cannot run for any reason, the ALT attribute defines text to be displayed on the webpage.
ARCHIVE="class_file,class_file,..."
If there are any class files that need to be preloaded, use the ARCHIVE attribute. If there are more than one file, separate them with commas.
CODE="URL"
This is the URL of the applet.
CODEBASE="URL"
This attribute is very similar to the BASE tag. It provides the URL of the applets for the webpage.
HEIGHT=number
This sets the height of the applet window.
HSPACE=number
This sets the horizontal space that surrounds the applet.
NAME="name"
This is the name of the applet.
OBJECT="name"
This is the name of a resource that contains the applet.
VSPACE=number
This is the vertical counterpart of HSPACE. This sets the vertical space around the applet.
WIDTH=number_or_percentageofscreen
This is the horizontal counterpart of HEIGHT. This sets the width of the applet window either in pixels or percentage of total screen width.

The PARAM Tag

You will probably want to pass information to the applet in the form of parameters. In DragonClock we pass a number to represent the value of the background and foreground colors. The parameters go between the <APPLET> and </APPLET> tags. The attributes of the PARAM tag are:

NAME="name"
This specifies the name of the parameter.
VALUE=number_or_"text"
This is the value assigned to the parameter. This is the value that will be passed to the applet.
VALUETYPE=data_or_ref_or_object
This specifies how to interpret the VALUE. VALUETYPE can be one of three possibilities:
  1. DATA - The default type. The value is data.
  2. REF - The value is a URL
  3. OBJECT - The value is the URL of an object.
TYPE=type
This specifies a MIMETYPE.

Putting It All Together

Here is the APPLET and PARAM tags for DragonClock:

Instructions for supplying the parameters are given in comment form so as not to show on the webpage.

Final Comments

Now we have talked briefly about Java and object oriented programming. We have written an applet to display a digital clock. And we have attached the applet to a webpage. That is all there is to it. There is much more to learn about Java and applets, but that is beyond the scope of this tutorial. Hopefully, by this time you have a better understanding of writing applets. May your code be plentiful and your bugs be few.


Java and java Development Kit are trademarks of Sun Microsystems. All material is copyright of P & G Dragonsites and may not be reproduced in whole or in part in any media without prior permission.
For questions or comments please contact us at pgdragonsites@thecenter.zzn.com



Reprinted with permission from the author. Click here to visit the original version
Download this tutorial (~30 KB)

How to Add Java Applets to Your Site

New on the Java Boutique:

New Review:

Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling API boasts simplicity, ease-of-integration, a well-rounded feature set, and it's free!

New Applet:

Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA sequences into three useful formats.

Elsewhere on internet.com:

WebDeveloper Java
Lots of Java information on webdeveloper.com

WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.

ScriptSearch Java
Hundreds of free Java code files to download.

jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.

 Microsoft Visual Studio 2010 Showcase
 Avaya Developer Showcase
 MSDN Spotlight
 PHP for Windows Showcase
XML error: undefined entity at line 39
advertisement
Receive Articles via our XML/RSS feed
Receive Articles via our XML/RSS feed

JavaBytes
Internet Cyclone
This powerful, easy-to-use, internet optimizer is for Windows 95, 98, ME, NT, 2000 and XP. It's designed to automatically optimize your Windows settings, boosting your Internet connection up to 200%.

Windows 7: From Beta to Final Code in One Year
Google Shows Off Chrome OS, Releases Source
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?
Fedora 12 Takes Aim at Linux Networking
Top Supercomputer Nearly Doubles in Speed
Fedora 12 Linux Tackles Virtualization
Apple Gives iPhone Developers App Status Tracker
Novell Sets OpenSUSE 11.2 Free

Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Exploring HTML 5's Audio/Video Multimedia Support
Overriding Virtual Functions? Use C++0x Attributes to Avoid Bugs.
Understanding the Cloud Computing Security Vulnerabilities
Cisco and IBM Target a Greener World
Upgrade to Visual Studio 2010 with the Ultimate Offer

Advertising Info  |   Member Services  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs