return Download.STATUSES[download.getStatus()];
return "";
This method first looks up the Download corresponding to the row specified. Next, the
column specified is used to determine which one of the Download's property values to return.
The update( ) Method
The update( ) method is shown here. It fulfills the Observer interface contract allowing the
DownloadsTableModel class to receive notifications from Download objects when they
/* Update is called when a Download notifies its
observers of any changes. */
public void update(Observable o, Object arg) {
int index = downloadList.indexOf(o);
// Fire table row update notification to table.
fireTableRowsUpdated(index, index);
This method is passed a reference to the Download that has changed, in the form of an
Observable object. Next, an index to that download is looked up in the list of downloads,
and that index is then used to fire a table row update event notification, which alerts the
table that the given row has been updated. The table will then rerender the row with the
given index, reflecting its new values.
The DownloadManager Class
Now that the foundation has been laid by explaining each of the Download Manager 's helper
classes, we can look closely at the DownloadManager class. The DownloadManager class is
responsible for creating and running the Download Manager 's GUI. This class has a main( )
method declared, so on execution it will be invoked first. The main( ) method instantiates a
new DownloadManager class instance and then calls its show( ) method, which causes it to
be displayed.
The DownloadManager class is shown here. Notice that it extends JFrame and implements
Observer. The following sections examine it in detail.
// The Download Manager.
public class DownloadManager extends JFrame
implements Observer
Search WWH :
Custom Search
Previous Page
Java SE 6 Topic Index
Next Page
Java SE 6 Bookmarks