Chapter 3: Using Java on Your Pages |
index | previous | next | ||||||||||||||||||||||||
|
|||||||||||||||||||||||||
Listing 3.3
Here's a way to move an applet from its default position.
![]() Fig. 3.4 Here the applet is aligned on the right-hand side of the window. Listing 3.4 Here's another way to move an applet around.
![]() Fig. 3.5 The applet now has a 100-pixel-wide border on every side. |
Positioning Java applets on the pageThe APPLET tag can be positioned on a Web page much like the IMG tag. Listings 3.3 and 3.4 show how an applet can be moved from the default alignment.
To position a Java applet:1. <APPLET CODEBASE="classes" CODE="HelloWorld.class" WIDTH=200 HEIGHT=50 ALIGN=RIGHT> In Figure 3.4, the HelloWorld applet is on the right side of the window. This is because the ALIGN attribute of the APPLET tag has been set to RIGHT. 2. <APPLET CODEBASE="classes" CODE="HelloWorld.class" WIDTH=200 HEIGHT=50 HSPACE=100 VSPACE=100> In Figure 3.5, the HelloWorld applet is surrounded by 100 pixels of white space on all sides, due to the settings of the HSPACE and VSPACE attributes.
|
Alignment | Meaning |
LEFT | Aligns the applet area flush left |
RIGHT | Aligns the applet area flush right |
TOP | Displays the applet area at the top of the available area |
TEXTTOP | Aligns the applet area with the highest text displayed adjacent to the applet area |
MIDDLE | Aligns the middle of the applet area with the baseline of adjacent text |
ABSMIDDLE | Aligns the middle of the applet area with the middle of the largest adjacent item |
BASELINE | Aligns the bottom of the applet area with the baseline of adjacent text |
BOTTOM | Aligns the bottom of the applet area with the bottom of adjacent text |
ABSBOTTOM | Aligns the bottom of the applet area with the bottom of largest adjacent item |