Java Reference
In-Depth Information
To Quit TextPad
1. Click the Close button on the right side of the TextPad title bar.
If you made changes to the project since the last time it was saved, TextPad
displays a TextPad dialog box. If you click the Yes button, you can resave
your file and quit. If you click the No button, you will quit without saving
changes. Clicking the Cancel button will close the dialog box.
Moving to the Web
One of the features that makes Java so useful is that programmers can use it to
develop programs that are machine-independent and can run on the Web. Much
of Java's portability lies in the use of applets. As you learned in Chapter 1, an
applet is a small program that can be downloaded and executed as part of a dis-
played Web page. When run as part of a Web page, applets often are used to per-
form interactive animations, immediate calculations, or other simple tasks
without having to access the computer that is hosting the Web page.
Other major differences between Java applications and Java applets exist.
One difference is that applications run as stand-alone programs with full access
to system resources, whereas applets can run only within a browser or viewer
and are usually delivered to the local computer via the Web. Another difference is
in their scope for data handling. An applet cannot be used to modify files stored
on a user's system, while an application can. Finally, unlike applets, applications
do not need a memory-intensive browser or viewer in order to execute.
The source code for the Welcome to My Day application is complete and can
be edited to convert the application into an applet that can run via the Web. The
steps to convert the application into an applet include opening the Welcome file
in TextPad, editing the code to import two new packages, changing the class
name, and specifying that the class is an applet. Then the class code is edited
to include a paint method that draws text in the applet window and displays a
graphic and color. Once the changes are complete, the file is saved and the applet
is compiled.
Opening an Existing File in TextPad
Once you have created and saved a file, you often will have reason to retrieve
it from disk. For example, you might want to revise the code or print it again.
Earlier you saved the Java source code file created in this chapter on a disk using
the file name Welcome. The steps on the next page illustrate how to open the file
Welcome.java from the Data Disk in drive A using TextPad.
Search WWH ::




Custom Search