O marcador APPLET
A presença de um applet num documento HTML é indicada pelo marcador <applet>, cuja sintaxe mínima tem a seguinte forma:<applet code="MyApplet.class" width=100 height=140></applet>Os três parâmetros do marcador definem:
- code
- a localização do código java (um URL)
- width e height
- uma área retangular de trabalho do applet dentro da página, em pixels (largura e altura, respectivamente).
Sintaxe completa do marcador APPLET
'<' '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.
Exemplo mais complexo
<applet codebase="http://java.sun.com/applets/applets/NervousText"
code="NervousText.class" width=400 height=75 align=center>
<param name="text" value="This is the Applet Viewer">
<blockquote>
<hr>
Se você estivesse usando um folheador compatível com Java,
veria um applet no lugar deste texto.
<hr>
</blockquote>
</applet>
Onde fica o código Java de um applet?
Podemos facilmente descobrir a localização do código Java com:Onde fica o código-fonte? E o código compilado?
- URL do documento onde está inserido o applet
- opções CODE e CODEBASE do marcador APPLET.
Referências
| José Fernando Tepedino (jftm@di.ufpe.br) |