Homework 3: Generating events

Objective

In this homework assignment, we want you to become familiar with dispatching events from the custom JCalendar widget you created in the first two homework assignments.

Description

You are asked to modify your JCalendar component to dispatch a DateEvent to any DateListener that registers interest for those events from the JCalendar component. You are provi ded with the JTestFrame.java and JThumbnailPanel.java files. Both java files implement the DateListener interface and will react to the date specified b y the user.

  •  
You must create the DateListener interface. A DateListener gets notified when a new date specified by the user through the callback method dateSpecified() which takes in a DateEvent as a parameter.
  •  
A DateEvent (an object class you must define) should extend the AWTEvent object. It supports three accessor methods (getMonth(), getDay(), and getYear()) which return the int value month, day and year of the date specified by the user respectively.

To allow DateListeners to register and unregister interest for DateEvents generated through your JCalendar component, it must implement the following methods:

Your JCalendar component will need to fire a DateEvent when the user inputs a new date to the registered DateListeners. The JTestFrame will update the textfields showing the date. The JThumbnailPanel will crawl Yahoo's News Photo archive for pictures from news stories for that date.

You will need to modify your JCalendar component to remain responsive to user input even though other parts of the application may not be very quick in reacting to input. For example, when the JThumbnailPanel fetches pictures for a particular date, if the user continues to input date information through your JCalendar component, it should still be able to recognize all the input the user specifies despite the delay in disp lay introduced by that component. Because the JTestFrame is also a registered listener for the DateEvents generated through your JCalendar component, it should be receiving it at the same rate of input despite the slo w JThumbnailPanel. Don't worry about it showing up in the JThumbnailPanel slowly because that is something we intentionally introduced.

Hint: Towards the bottom of this Web page, the tutorial discusses how GUIs can become frozen and offers advice on how to solve this problem: http://java.sun.com/docs/books/tutorial/uiswing/overview/event.html . You will need to adapt their solution.

Note: images will only show for dates after 8/15/2003, when Yahoo began archiving this information.

Deliverable

Please work on this homework assignment alone; please do not consult others.

This homework assignment should be done in JAVA, and needs to be compiled to run using SUN's JDK 1.4 or higher.

Your JCalendar must work with the JTestFrame.java and JThumbnailPanel.java files provided.

Please zip up source code and mail the zip file to the TA () when you have completed the assignment (and remember to CC yourself on the email).

The due date for this assignment is: September 29, 2003, 1:00 PM EST.