

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Assigned
: November 26, 2008
Due
: December 10, 2008 @ 12:00pm (submitted before class starts)
Submission Method
: Email solution to [email protected] by due date.
Please identify your submission in the email subject header as being homework 6. Attach the source
(^) fi le(s) containing the
modi
fi ed application, your comparison classes, and the modi
fi ed
Song
(^) class. You may attach multiple source
(^) fi les separately
or archive them using a mainstream archiver (.zip, .sit, .tar.gz, etc.). If you are sending loose
(^) fi les, please create a proper email
attachment rather than copy/pasting one after the other. If you send an unreadable
fi le or archive, the instructor will generally
notify you that you need to resubmit it, but the homework is not considered turned in until the instructor gets a readable
(^) fi le.
To get started, download
(^) Homework6.java
from the class website. This class contains a simple application for displaying a
sorted list of
Song
s that can be reordered by the user by clicking on the table headers. A method has been stubbed out to
privateperform the actual ordering:
Collection
When the user clicks on a table header, a
(^) MouseListener
is informed and calls this method, passing it the current
collection of songs and a desired sort
fi eld. The value of
(^) fi eld will be either โ
title
artist
category
โ, or โ
year
depending on which of the
(^) Song
(^) fi elds the collection should be ordered by. This method should make use of
Comparable
Comparator
(^) objects to return a sorted collection. The application will then update the table with the objects in the new
The application contains an example of using theordering.
(^) JTable
class to display data. This GUI component is paired with a table
model class which performs transformations between the {
row
(^) column
} lookups used by tables and the accessor calls used
The table is enclosed in aon data model objects. It also supplies information like row and column counts and column header names to the table.
JScrollPane
, which displays scroll bars as necessary if the table contents should exceed the size
of the window.
a