img
.
Handling Action Events
Each of DownloadManager 's GUI controls registers an ActionListener that invokes its
respective action method. ActionListeners are triggered each time an action event takes
place on a GUI control. For example, when a button is clicked, an ActionEvent is generated
and each of the button's registered ActionListeners is notified. You may have noticed
a similarity between the way ActionListeners work and the Observer pattern discussed
earlier. That is because they are the same pattern with two different naming schemes.
Compiling and Running the Download Manager
Compile DownloadManager like this:
javac DownloadManager.java DownloadsTableModel.java ProgressRenderer.java Download.java
Run DownloadManager like this:
javaw DownloadManager
The Download Manager is easy to use. First, enter the URL of a file that you want to
download in the text field at the top of the screen. For example, to download a file called
0072229713_code.zip from the McGraw-Hill web site enter
http://books.mcgraw-hill.com/downloads/products/0072229713/0072229713_code.zip
After adding a download to the Download Manager, you can manage it by selecting it
in the table. Once selected, you can pause, cancel, resume, and clear a download. Figure 33-2
shows the Download Manager in action.
FIGURE 33-2
The Download Manager in action
Search WWH :
Custom Search
Previous Page
Java SE 6 Topic Index
Next Page
Java SE 6 Bookmarks
Home