Chapter 9
Additional Web Questions
Please answer the following true or false questions:
1. A JButton can display text, an image, or both.
2. All images must be in JPEG format to be used by Java.
3. For use with buttons and labels, images should be converted into ImageIcon objects.
4. All images and sound files are referenced as URLs.
5. All images and sound files must be on the same computer as the applet.
6. The following are valid methods for an AudioClip: play, stop, and repeat.
7. A Font controls how text is displayed.
8. All computers have the same set of fonts.
9. Bold and italic are examples of font styles.
10. All Java colors are a mixture of red, green, and blue.
Answers:
1. true.
The JButton class can display text, images, or both. In fact, it can display different images when the mouse pointer is over the button, and when the button is pressed.
2. false.
Java supports many image formats, including, but not limited to, JPEG, GIF and Bitmap.
3. true.
The ImageIcon class really makes using images much easier. If you are using images from various locations on the Internet, the ImageIcon class takes care of all of the downloading details that you really don't want to bother with. Trust us. In the days before the ImageIcon class, loading images was a big pain in the assembler!
4. true.
URLs (Uniform Resource Locators) are the "filenames" of the Internet. No self-respecting Internet-programming language would use anything less.
5. false.
See Question 4, above. Since all file references are URLs, then files can be anywhere on the Internet. Of course, they still can be local, too.
6. false.
The methods for the AudioClip class are: start, stop and loop. Perhaps you were thinking of the Shampoo class: lather, rinse, repeat.
7. true.
A font specifies the shape (family), size, and style of displayed text.
8. false.
While there are fonts common to most computers, you can't count on specific fonts being everywhere.
9. true.
Font styles are:
· plain
· bold
· italic
· bold-italic.
10. true.
All Java colors have red, green, and blue (RGB) values that range from 0 to 255 each. This allows for over 16 millions colors.