Internet and Web Resources

Answers to Self Review Exercises

21.1

a) getImage. b) drawImage. c) AudioClip. d) image map. e) paintIcon. f) Graphics Interchange Format (GIF), Joint Photographic Experts Group (JPEG), Portable Network Graphics (PNG).

21.2

a) True. b) False. ImageIcon can load images from the Internet as well. c) False. Method play of class AudioClip plays an audio clip once. Method loop of class AudioClip continuously loops an audio clip. d) False. The Java 3D API is used for creating and modifying 3D graphics. The Java Image I/O API is used for reading from and outputting images to files. e) True.

Exercises

21.3

Describe how to make an animation "browser friendly."

21.4

Describe the Java methods for playing and manipulating audio clips.

 
21.5

Explain how image maps are used. List several examples of their use.

21.6

(Randomly Erasing an Image) Suppose an image is displayed in a rectangular screen area. One way to erase the image is simply to set every pixel to the same color immediately, but this is a dull visual effect. Write a Java program that displays an image and then erases it by using random-number generation to select individual pixels to erase. After most of the image is erased, erase all the remaining pixels at once. You can draw individual pixels as a line that starts and ends at the same coordinates. You might try several variants of this problem. For example, you might display lines randomly or display shapes randomly to erase regions of the screen.

21.7

(Text Flasher) Create a Java program that repeatedly flashes text on the screen. Do this by alternating the text with a plain background-color image. Allow the user to control the "blink speed" and the background color or pattern. You will need to use methods getDelay and setDelay of class Timer. These methods are used to retrieve and set the interval in milliseconds between ActionEvents, respectively

21.8

(Image Flasher) Create a Java program that repeatedly flashes an image on the screen. Do this by alternating the image with a plain background-color image.

21.9

(Digital Clock) Implement a program that displays a digital clock on the screen.

21.10

(Calling Attention to an Image) If you want to emphasize an image, you might place a row of simulated light bulbs around it. You can let the light bulbs flash in unison or fire on and off in sequence one after the other.

21.11

(Image Zooming) Create a program that enables you to zoom in on or out from an image.

Категории