Username: Save?
Password:
Home Forum Links Search Login Register*
    News: Keep The TechnoWorldInc.com Community Clean: Read Guidelines Here.
Recent Updates
[Today at 11:48:22 AM]

[Today at 11:48:22 AM]

[Today at 11:48:22 AM]

[Today at 11:48:22 AM]

[April 03, 2024, 06:11:00 PM]

[April 03, 2024, 06:11:00 PM]

[April 03, 2024, 06:11:00 PM]

[April 03, 2024, 06:11:00 PM]

[March 06, 2024, 02:45:27 PM]

[March 06, 2024, 02:45:27 PM]

[March 06, 2024, 02:45:27 PM]

[March 06, 2024, 02:45:27 PM]

[February 14, 2024, 02:00:39 PM]
Subscriptions
Get Latest Tech Updates For Free!
Resources
   Travelikers
   Funistan
   PrettyGalz
   Techlap
   FreeThemes
   Videsta
   Glamistan
   BachatMela
   GlamGalz
   Techzug
   Vidsage
   Funzug
   WorldHostInc
   Funfani
   FilmyMama
   Uploaded.Tech
   MegaPixelShop
   Netens
   Funotic
   FreeJobsInc
   FilesPark
Participate in the fastest growing Technical Encyclopedia! This website is 100% Free. Please register or login using the login box above if you have already registered. You will need to be logged in to reply, make new topics and to access all the areas. Registration is free! Click Here To Register.
+ Techno World Inc - The Best Technical Encyclopedia Online! » Forum » THE TECHNO CLUB [ TECHNOWORLDINC.COM ] » Programming Zone » JAVA
 APPLET - Java Applet
Pages: [1]   Go Down
  Print  
Author Topic: APPLET - Java Applet  (Read 4671 times)
Mark David
Administrator
Super Elite Member
*****



Karma: 185
Offline Offline

Posts: 1624

!!!Techno King!!!

fabulous_designer
View Profile WWW
APPLET - Java Applet
« Posted: March 31, 2007, 08:16:31 PM »


APPLET - Java Applet

Syntax    <APPLET>...</APPLET>

Attribute Specifications    

    * CODE=CDATA (class file)
    * CODEBASE=URI (base URI for class files)
    * WIDTH=Length (applet width)
    * HEIGHT=Length (applet height)
    * ARCHIVE=CDATA (archive files)
    * OBJECT=CDATA (serialized applet)
    * NAME=CDATA (name for inter-applet communication)
    * ALT=Text (alternate text)
    * ALIGN=[ top | middle | bottom | left | right ] (applet alignment)
    * HSPACE=Pixels (horizontal gutter)
    * VSPACE=Pixels (vertical gutter)
    * common attributes

Contents    PARAM elements followed by block-level elements and/or inline elements
Contained in    Inline elements, block-level elements except PRE

The APPLET element is used to embed Java applets. It has been deprecated in HTML 4 in favor of the more generalized OBJECT element. However, since the few browsers that support OBJECT do so with significant bugs, APPLET is currently a more reliable method of embedding Java applets.

APPLET's CODE attribute specifies the name of the class file that contains the compiled Applet subclass. The value is relative to the URI specified in the CODEBASE attribute, or to the HTML document's base URI if the CODEBASE attribute is not given.

The required WIDTH and HEIGHT attributes define the dimensions of the applet. The value may be given in pixels or as a percentage of the parent element's width or height.

The ALT attribute can be used to give alternate text for browsers that recognize the APPLET element but do not support Java or do not have Java enabled. Authors can also give alternate content between the start and end tags of the APPLET element--a better method than using the ALT attribute since it allows authors to include HTML markup in the alternate content and also works with pre-HTML 3.2 browsers that do not support APPLET.

An APPLET may contain PARAM elements to define applet-specific parameters. PARAM elements should be specified before any other content of the APPLET element. In the following example, a decorative Java applet takes two parameters. The APPLET contains an animated GIF as an alternative for non-Java browsers.

<APPLET CODE="Animate.class" WIDTH=100 HEIGHT=100>
<PARAM NAME=img1 VALUE="/images/1.jpg">
<PARAM NAME=img2 VALUE="/images/2.jpg">
<IMG SRC="animation.gif" ALT="" WIDTH=100 HEIGHT=100>
</APPLET>

The ARCHIVE attribute can specify a comma-separated list of archived files (either absolute URIs or URIs relative to the CODEBASE), allowing the browser to download many files with a single connection and hence decreasing the total download time. The standard archive format for Java files is JAR. JAR files can be created with the jar tool included with the Java Development Kit.

Note that some browsers do not support the ARCHIVE attribute, so all necessary files should be available unarchived as well. Other browsers only support a single URI as the ARCHIVE value.

The OBJECT attribute specifies a serialized (saved) representation of an applet. The CODE attribute should not be used if and only if the OBJECT attribute is specified. When the applet is deserialized, its init() method is not invoked, but its start() method is. Sun recommends restraint in using this poorly supported feature.

The ALIGN attribute specifies the alignment of the applet. The values top, middle, and bottom specify the applet's position with respect to surrounding content on its left and right.

ALIGN=middle aligns the vertical center of the applet with the current baseline. To center the applet horizontally on the page, place the applet in a centered block, e.g.,

<P ALIGN=center><APPLET CODE="Game.class" WIDTH=300 HEIGHT=100></APPLET></P>

The other ALIGN values, left and right, specify a floating applet; the applet is placed at the left or right margin and content flows around it. To place content below the applet, use <BR CLEAR=left|right|all> as appropriate.

The vertical-align and float properties of Cascading Style Sheets provide more flexible methods of aligning applets.

The HSPACE and VSPACE attributes allow an author to suggest horizontal gutters and vertical gutters, respectively, around the applet. The value must be in pixels and applies to both sides of the applet. Style sheets provide more flexibility in specifying the space around applets.

Logged

« Reply #1 Posted: March 31, 2007, 08:18:05 PM »
Mark David
Administrator
Super Elite Member
*****



Karma: 185
Offline Offline

Posts: 1624

!!!Techno King!!!

fabulous_designer
View Profile WWW
Re: APPLET - Java Applet
« Reply #1 Posted: March 31, 2007, 08:18:05 PM »

All applets are extended from a class called java.applet.Applet and has the following methods:

init()   initializes the applet
start()   starts the applet
stop()   stops the applet
destroy()   cleans up resources when applet is finished
getAudioClip(URL url)   retrieves an audio clip
getAudioClip(URL url, String name)   overloaded method that allows the specification of the name of the audio clip
getCodeBase()   returns URL where the applet resides
getDocumentBase()   returns URL of HTML page where applet is embedded
getImage(URL url)   retrieves image
getImage(URL url, String name)   retrieves named image
getParameter(String name)   returns a parameter from HTML page
getParameterInfo()   returns an array of strings that enables you to retrieve more than one parameter to the applet
isActive()   returns Boolean identifying whether applet is active
play(URL url)   plays an audio clip
play(URL url, String name)   plays a named audio clip
resize(int width, int height)   resizes the applet
resize(Dimension d)   resizes the applet
showStatus(String msg)   prints message on the appletviewer's status bar or a browser's panel

Here's the complete syntax for the APPLET tag:

'<' 'APPLET'
['CODEBASE' '=' codebaseURL]
'CODE' '=' appletFile
['ALT' '=' alternateText]
['NAME' '=' appletInstanceName]
'WIDTH' '=' pixels 'HEIGHT' '=' pixels
['ALIGN' '=' alignment]
['VSPACE' '=' pixels] ['HSPACE' '=' pixels]
'>'
['<' 'PARAM' 'NAME' '=' appletAttribute1 'VALUE' '=' value '>']
['<' 'PARAM' 'NAME' '=' appletAttribute2 'VALUE' '=' value '>']
. . .
[alternateHTML]
'</APPLET>'

'CODEBASE' '=' codebaseURL
This optional attribute specifies the base URL of the applet -- the directory that contains the applet's code. If this attribute is not specified, then the document's URL is used.

'CODE' '=' appletFile
This required attribute gives the name of the file that contains the applet's compiled Applet subclass. This file is relative to the base URL of the applet. It cannot be absolute.

'ALT' '=' alternateText
This optional attribute specifies any text that should be displayed if the browser understands the APPLET tag but can't run Java applets.

'NAME' '=' appletInstanceName
This optional attribute specifies a name for the applet instance, which makes it possible for applets on the same page to find (and communicate with) each other.

'WIDTH' '=' pixels 'HEIGHT' '=' pixels
These required attributes give the initial width and height (in pixels) of the applet display area, not counting any windows or dialogs that the applet brings up.

'ALIGN' '=' alignment
This required attribute specifies the alignment of the applet. The possible values of this attribute are the same as those for the IMG tag: left, right, top, texttop, middle, absmiddle, baseline, bottom, absbottom.

'VSPACE' '=' pixels 'HSPACE' '=' pixels
These option attributes specify the number of pixels above and below the applet (VSPACE) and on each side of the applet (HSPACE). They're treated the same way as the IMG tag's VSPACE and HSPACE attributes.

'<' 'PARAM' 'NAME' '=' appletAttribute1 'VALUE' '=' value '>' . . .
This tag is the only way to specify an applet-specific attribute. Applets access their attributes with the getParameter() method.

ex.
<APPLET CODE = ImageLoopItem
CODEBASE=http://java.sun.com/applets/applets/ImageLoop/
width = 80
height = 90>
<PARAM NAME=nimgs VALUE=10>
<PARAM NAME=img VALUE=duke>
<PARAM NAME=pause VALUE=1000>
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Copyright © 2006-2023 TechnoWorldInc.com. All Rights Reserved. Privacy Policy | Disclaimer
Page created in 0.098 seconds with 24 queries.