
Put a NASA Photo into the Background of a Text Area #7
Chapter 1, Basic JComponents
|
29
HACK
H A C K
#7
Put a NASA Photo into the Background
of a Text Area Hack #7
This hack will repurpose an existing web page, one of NASA’s photo sites, by
pulling their “Astronomy Picture of the Day” into the background of a text
area.
You’ve already learned how to draw a watermark image in the background
of a text area
[Hack #6] using a ScrollPaneWatermark. This hack will pull a
photo down from the Web and reuse that class to put the photo in the back-
ground. The photo itself comes from NASA’s “Astronomy Picture of the
Day” page: http://antwrp.gsfc.nasa.gov/apod/. The URL to the image changes
each day, but the page itself does not. To pull the image down you will load
the page, find the image URL, then load the image itself and put it into the
ScrollPaneWatermark. Depending on the day, it may look something like
Figure 1-22.
Figure 1-21. Finished ScrollPane hack
Figure 1-22. Text area with a background image