<<

CS& 141 Project 4: " Date-Finder GUI" Name: You have already created a DateAD program for the command-line. You will now get to use that class to write a GUI that creates and uses a calendar to pick a date. In order to do this, you will need to use DateAD from the previous project, create a BasicCalendar class that utilizes DateAD, and create a JFrame to utilize the BasicCalendar. The classes you create should contain at least the following:

• BasicCalendar: contains information about one month properties: • public static finals (constants) for o number of ROWS in calendarArray (6) o number of COLUMNS in calendarArray (7) • private DateAD aDay -- used to hold the month and year. The dayOfMonth should always be set to 1 so that you will always know the dayOfWeek on which the month starts . • private int[][] calendarArray -- a 6x7 array (empty spots contain 0) methods: • 3 constructors -- one default, and ones with 1 (month) and 2 (month, year) parameters. Any missing parameter or out-of-range parameter will be replaced with the current value from the system. Should call setArray(). • private void setArray -- should properly fill in the array with the current calendar. • public int at -- accessor for one element (day) of the array, at(row, column) should return the value at calendarArray[row][column], or 0 if out-of-bounds. • public String toString -- returns the month, year and calendar (as text) on multiple lines (see sample below); overrides Object.toString() • CalendarFrame: JFrame class Create a Graphical User Interface that contains all of the same elements as the one shown below. You may use "Mattisse" in Netbeans, or you may build it from scratch. The GUI needs to contain elements of the types: • JLabel • JTextField • JComboBox • JTextArea Set the possible months in the "months" combo box; Set the possible years (twelve years, starting with the current year--use a loop) in the "years" combo box. Add the following properties: • private BasicCalendar • private short month • private short year • private short day • private DateAD date Set the font in the textArea to a fixed-width font, such as "Courier New" In the constructor, set the values of all the appropriate fields and properties to today's date's values. Set the title to "Calendar by " Add actionListeners for the day text field, the month combo box and the year combo box. Have them make all appropriate changes when a new selection is entered. The program should act in the same manner as the sample. An invalid entry for the day should restore the day to the previous value. An invalid day when the month or year is changed should set the day as the last day in that month. A screen shot of the program might look like:

A working model of this program is available on Canvas . You can run the program by unzipping all and then either typing (at the command prompt): java -jar Calendar.jar or double-clicking on Calendar.jar in Windows Explorer (if the file is on the local computer and not on the network). You may use this sample program to compare answers in your test . Deliverables:

Physical: The Project should be turned in inside a clear plastic file folder. This folder should have a simple flap to hold paper in place--NO buttons, strings, Velcro, etc. Pages should be in order, not stapled. • Assignment Sheet (printed pdf from the web), with your name on it, as a cover sheet. • Printed Source Code with Comments (you do not need to print out DateAD.java) (including heading blocks -- a file header for each file plus a function header for each function. Describe parameters, any input or output, etc., no line wrapping). Print in portrait mode, 10 - 12 point font. Electronic: • All .class, .jar, .html (javadocs), and .java files. • Sample Output (as .rtf -- run the program, copy the window using , paste into Paint, invert colors (), copy, open Wordpad, paste, save.) • A simple test plan including explanations of any discrepancies and reasons for each test. Show actual input and ALL values output as well as ALL expected output. Test each possible action. Save as .xls, xlsx, .doc or .docx file • Zip all of the above files together. Do not use rar or any archive format other than zip. Rename the file: "_p4.zip". • Submit this single zip file by going to Canvas, select this class, select the Assignment tab on the left, select the Assignment 4, select the submission tab at the top, find the file, and Submit. Due: Tuesday, March 10, 2015 11:30 a.m (beginning of class)