Java Reference
In-Depth Information
Hello World!
Figure 1.4
Display of a very basic applet.
HelloWorld .) Then compile the code with
> javac HelloWorld.java
This creates the class file HelloWorld.class .
Applets are intended for display in browsers so you need to create a Web page
file with the proper tags that indicate where the browser should find the class
code and how big a window it should provide to display the applet's graphical
output. (A brief tutorial on HTML coding for Web pages is available in the Web
Course Chapter 1: Supplements section.)
Put the following code into a file called HelloWorld.html :
< html >
<head>
< title > A Simple Applet < /TITLE >
</head>
< body >
<applet code ="HelloWorld.class" width =";150" height ="50">
</applet >
</body>
</html >
With this < applet > tag the file must reside in the same directory as the
HelloWorld.class file. Open the file HelloWorld.html in your browser
and you should see something like that in Figure 1.4.
1.8.4 Starter programs
We provide with the Web Course the codes for a number of programs that act as
templates into which you insert code to make them do something useful. Since
the term “template” implies something else in object-oriented programming, we
call these starter programs. You can use them to begin a program without starting
from scratch every time.
Avery simple application program, StartApp1.java ,isshown here. You
can insert code snippets, such as those to be discussed in Chapter 2, into the area
indicated.
Search WWH ::




Custom Search