|
To access the contents, click the chapter and section titles.
Sams Teach Yourself Visual J++ 6 in 21 Days
Editing the HTML FileEditing the HTML file is an easy way to change the position at which your applet appears. You can center the applet, justify it on the left side of the browser screen, or justify it on the right side of the browser screen. Many of the applets created in this book will have parameters that reside in the HTML file. Changing them will alter the behavior of the applet. After the three HelloWorld files are on the server in the correct directory, the main HTML file must be edited so that users have the chance to bring up your applet. As mentioned earlier, the main HTML file on your Web server will probably have a special name such as index.html. Theres a difference between writing an applet and testing it on a local machine, and uploading to a Web server and testing on the server. Details such as what the name of the default (main) HTML page is are important. For now, youll have the main HTML file bring up HelloWorld.html. Open your main HTML file in a text editor. Add the following line: <h3><p>Run <a href=HelloWorld.html> <i>HelloWorld</a></h3><p> A new line will appear when your browser opens the HTML at your site, as shown in Figure 3.6.
When you click on the HTML line, youll see the HelloWorld applet run in your browser. The source code is available for viewing with a line at the bottom labeled The source, as shown in Figure 3.7. All HTML files created by J++ make the source code available.
Now that you know how to make the changes in the HTML file for the HelloWorld applet, its time to take a look at the complete file. Listing 3.1 has the HTML source code for the HelloWorld applet. Listing 3.1 The Complete HelloWorld.html File 1 <HTML> 2 <HEAD> 3 <TITLE>HelloWorld Test HTML Page</TITLE> 4 </HEAD> 5 <BODY> 6 <applet 7 code=HelloWorld.class 8 name=HelloWorld 9 width=320 10 height=200 > 11 <param name=label value="Hello Visual J++ World."> 12 <param name=background value="008080"> 13 <param name=foreground value="FFFFFF"> 14 </applet> 15 16 <hr> 17 <a href="HelloWorld.java">The source.</a> 18 <a href="HelloWorld.zip">The source zipped.</a> 19 20 </BODY> 21 </HTML>
SummaryUploading your applets to a Web server is an important part of the development process. Its one you need to be familiar with so that you can do it without a lot of aggravation. Editing your HTML files is important too. The appearance of your Java program relies on your ability to edit the HTML file and correctly set the applet parameters. A good tool to use for uploading files is WS_FTP. A trial version can be downloaded and used free of charge for a limited time.
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |