Java Reference
In-Depth Information
6. Set the background color to yellow.
7. Use the drawString() method to print the words “This is a color test” at the
coordinates 25 and 30.
8. Enter closing braces to close the method and class.
9. Compile the program. Fix errors as necessary.
10. On the TextPad menu bar, click File and then click New. Type the HTML
code to reference the MyColor.class with a width of 400 and a height of 200.
Be sure to include the start and end <HTML> tags.
11. Save the HTML document with the filename MyColorApplet. Make sure you
specify the HTML (*.htm*,*.stm*) file type.
12. Run the program.
13. Edit the program several times and change the color to red, blue, cyan, and
orange. Compile and then run the program after each color change.
7 Rick's Riding Rodeo
Rick's Riding Rodeo plans to market its line of saddles on the Web next year.
In preparation for Rick to begin e-commerce, write a Java application to display
the name of the store on the screen. Use appropriate documentation lines. Com-
pile the program and execute it. Once the program executes with no errors, edit
the program to include Rick's e-mail address (RideWithRick@rodeo.com). Save,
compile, and execute the program again. Convert the program to display as an
applet, and add an appropriate logo (your instructor may supply you with a
graphic, or you may download a graphic from the Web). When the applet is
complete and generates no compilation errors, write the HTML code to run
the applet.
8 Accessing the System Date
Your school would like to print out the programmer's initials and the system
date on all printouts from the mainframe computer. As a prototype, write a
Java program to print your initials and the system date on a splash screen. Use
the escape characters and spacing to print the letters in the correct locations.
Compile and execute your program. Print the source code.
9 Looking at Applets
The Web contains many sites that have free Java applets that you may download.
Use a search engine to search for Java applets on the Web. When you find a Web
page with some applets, use your browser's View Source command to look at the
coding. Within that code, look for tags such as <APPLET CODE = >. Print three
examples to submit to your instructor.
Search WWH ::




Custom Search