Java Reference
In-Depth Information
4 Converting an Application to an Applet
After completing the splash screen in Programming Assignment 3, you decide to
convert the application into an applet. Perform the following steps.
1. Change the file and class name to SplashApplet every time it displays in the
code.
2. Add the words, extends Applet, to the class header.
3. Change the main() method header to a paint() method header.
4. Change each println() method to a drawString() method. Remember to
reference the Graphics object (g) as you did on pages 96 and 97.
5. Save the program with the new file name, SplashApplet.
6. Compile the program. If there are errors, fix them in the SplashApplet
coding window and then compile again.
7. Create an HTML host document that calls the SplashApplet class. Set the
attributes of the applet to have a width of 400 and a height of 300 when it
displays in the Applet Viewer window.
8. Run the program.
9. Print a copy of the applet interface by using the Applet menu in the Applet
Viewer window. Using TextPad, print a copy of the source code for the Java
applet and the HTML code for the host document.
10. For extra credit, edit the program to include a system date.
5 Formatting Output Using Escape Characters
Computer applications typically display a splash screen for users to view while
waiting for the entire application to load. The Computer Science department at
Middle Illinois College wants to display a splash screen with the school's initials,
MIC, as each application loads. The display should use text characters to make
large versions of the letters M, I, and C, as shown in Figure 2-76.
FIGURE 2-76
(continued)
Search WWH ::




Custom Search