Skip to main content
Logo image

Java, Java, Java: Object-Oriented Problem Solving, 2024E

Section 15.3 Using Multimedia Network Resources for a Graphical Program

Suppose you want to write an graphical program that will display a catalog consisting of images or documents that you’ve prepared and stored on your Web site. Perhaps you can use such a program to give people who visit your site a downloadable tour of your campus as a slide show. Or perhaps a company might use such a program to advertise its products. In addition to making the catalog available through its main Web site, you can imagine it running continuously as a slide show on a computer kiosk in the company’s lobby.
In order to solve this problem we have to be able to download and display Web resources. As you know, Web resources are multimedia. That is, they could be documents, images, sounds, video clips, and so on. All Web resources are specified in terms of their Uniform Resource Locators (URLs). Thus, to download an image (or an HTML file or audio clip), we usually type its URL into a Web browser. We want our program to know beforehand the URLs of the images it will display, so there won’t be any need for inputting the URL. We want to implement something like the following algorithm:
A URL specification is just a String, such as, "http://www.cs.trincoll.edu/~ram/jjj/labs/ch09/slideshow/demo/demo0.gif" which describes how to retrieve the resource. First, it specifies the protocol or method that should be used to download the resource (http). Then, it provides the domain name of the server that runs the protocol and the port number where the service is running (www.cs.trincoll.edu:80). Next, the URL specifies the resource’s file name (ram/jjj/labs/ch09/slideshow/demo/demo0.gif).
You have attempted of activities on this page.