Inclusion of Java applet in document HTML.
Java applet, as well as the program on JavaScript, should be carried out from hypertext document HTML. with this property of applets the origin of the term " carried out contents " is connected. To include applets in file HTML, ispul`zuetsja HTML-teg <applet>. Teg <applet> is container tegom. It means, that in the text of the hypertext document behind it tegom should be necessarily specified closing teg </applet>. I bring syntax tega <applet> (unessential attributes are selected with dark blue color) below.
<applet
code = "File.class"
codebase = "ClassDirectory"
width=w
height=h
vspase=vs
hspace=hs
alt=text
name=appletName
align=left | right | top | middle | baseline | bottom |
<param name=ParamName value=ParamValue>
HTMLTekst...
</applet>
Where the attribute code sets a name of a loaded file with expansion .class, codebase - a name of the catalogue which contains the given file (files) with expansion .class, width - width of area of a conclusion of the applet in pixels, and height - its{her} height. To use inverted commas (") in names of arguments unessentially. Teg <param> it is intended for the task of names (ParamName) and values (ParamValue) parameters which are passed the applet from file HTML. The task several tegov <param.> HTMLText - the text intended for users which apply the browsers which are not supporting language Java is supposed. This text is displayed in that kind in what it is specified in ground tege. He should be set in format HTML, and his{its} length is not limited. The attribute alt is intended for a conclusion of the test in windows of browsers which distinguish teg <applet>, but cannot execute the applet. The attribute align, on the action is similar tegu <img align =... scr>. The attribute align is intended for the task of a way of accommodation of area of a conclusion of the applet for page. Attributes vspace and hspace set the sizes of a field of empty space above and under area of a conclusion of the applet (values of both attributes are specified in pixels).
For example it is possible to set the following teg <applet>:
<applet code = "MyApplet.class"
codebase = "CLASSES"
width=150
height=150
<hr> To viev this applet you will need a Java-aware browser! <p>
<img scr = "scrndump.gif"> <hr>
</applet>
This teg carries out a call of MyApplet.class applet. For the user who is looking through the given page with the help of a browser who does not support Java, on the screen the text " To viev this applet you will need a Java-aware browser will be displayed! " (For viewing this applet you need a browser supporting Java), and also a graphic representation (set in tege <img scr...>). Authors of some applications prefer to deduce{remove} in such cases instead of the text "picture" - such what would be seen on the screen by the user, raspologajuhhij supporting Java a browser. At start the area of a conclusion of the applet will borrow{occupy} a square site of the screen in the sizes 150kh150 pixels. The developer of the applet should take care of that the data deduced{removed} by the applet did not get for limits of the area selected for them. (In applets it is possible to set the sizes of area of display in which will be the information is deduced. If with the help of unessential attributes width/heigh the area of a conclusion of the applet the data will be deduced{removed} and be displayed in the field of the screen, set in the applet is not set.) Inclusion of the applet in page without sootvetsvujuhhego the text intended for those users at which browsers, not podderdivajut Java, it is considered to be impolite. By attribute codebase in this example it is set, that file MyApplet.class is in subdirectory CLASSES of the catalogue which contains a HTML-file.
Example of use tegov <applet>.
Let's consider the following example:
<applet code = "MyApplet.class" codebase = "myclasses">
???»«?«????n applet here!
</applet>
In this fragment of text HTML the attribute codebase sets the catalogue myclasses. This catalogue is subdirectory of the catalogue from which given file HTML has been loaded. For example if above mentioned tegi are part of HTML-file C:AppletsDemo_Applet.html the browser will search for file MyApplet.class in catalogue C:Appletsmyclasses.
Above mentioned teg <applet> it is possible to use for a call of local applets (for example to check up the applet all over again on the computer, and then already to place it{him} on the Web-server). The note: Not all applets can locally be carried out.
Certainly, the applet can be placed not only in that catalogue where there is file HTML causing it, and and in any other place Internet. In such cases in attribute codebase it is necessary to specify URL a file of the applet with expansion .class, for example:
<applet code = "RemoteApplet.class"
codebase = " http: // www.somehost.com/appletdir/classes / ">
Example of the applet.
</applet>
In this example RemoteApplet.class applet located on host Internet www.somehost.com in the catalogue/appletdir/classes/is caused. To load the applet in your system, the browser uses the transfer protocol of hypertext documents (HyperText Transfer Protocol - HTTP), and performance of the applet is carried out under the control of nucleus Java built - in a browser.
If you have decided to pass your applets to the Web-server (through FTP), be convinced, that in a HTML-file in which they are used, the attribute codebase is correctly set. If the file of the applet with expansion .class is in the same catalogue, as the corresponding HTML-file causing the given applet, i.e. containing teg <applet>, the attribute codebase can be lowered{omitted} in general. Better, however, if it is possible, to store{keep} files with expansion .class and initial texts of programs in language Java in different catalogues.
Insert of clips on page
<Embed scr = " {a name of a file with expansion} "> - an insert of an audio record
Width = " {number} " - the size of an audio record across
Height = " {number} " - the size of an audio record on a vertical
Autostart = {value} - autostart or start on pressing the button
True - right after start, False - start after pressing the button
Loop=True - cycling of a sound
For example: <Embed scr = "file.wav" Width = " 15 % " Height = "27" Autostart=True Loop=True>
<Embed scr = " {a name of a file with expansion} "> - an insert of video
Width = " {number} " - the size of video across
Height = " {number} " - the size of video on a vertical
Autostart = {value} - autostart or start on pressing the button
True - right after start, False - start after pressing the button
Loop=True - cycling of a clip
Controller = " {value} " - is / is not present a key of management of reproduction
True - is, False - no
For example: <Embed scr = "file.wav" Width = " 15 % " Height = "27" Autostart=True Loop=False Controller=True>

|