Application Assignment 2
Due Friday 4/30/2021
The assignment must be submitted by Friday, April 30th at 11:59pm. Submitting your assignment early is recommended, in case problems arise with the submission process. Late submissions will be accepted (but penalized 30pts) up to one week after the submission deadline. After that, assignments will not be accepted.
Create a GUI and additional functions for your classes from the first application assignment.
1. Commands will all be entered through the GUI instead of the console
a. All commands from application assignment 1 should be handled
b. Additionally, the application will let users update the names of InvItems using the command format [rename] [item#] [name], like "rename 1 wrench" to change item 1's name to wrench.
2. The GUI class will be named InvFrame and will be a subclass of JFrame. Any sensible arrangement of GUI components is acceptable, so long as all required functions are present.
a. There will be a JTextField to enter commands via the GUI instead of the console
b. There will be a JTextArea object to display output
c. After any command is entered, a) and b) will both be cleared, and then the output will be displayed in b)
3. The application will allow users to save and load arrays of InvItem objects.
a. The GUI will have additional JButtons labeled as "save" and "load"
b. The GUI will have an additional JTextField labeled as "filename"
c. Pressing the save button will save the current InvItem array to the file specified in the filename textbox in the local directory
d. Pressing the load button will replace the current InvItem array with the contents of the file specified in the textbox, from the local directory
4. Error-checking - Besides the usual checked exceptions for file operations, the following cases must be handled by the application:
a. An InvItem name that contains characters other than letters, spaces, and hyphens will not be accepted. Attempting to create an InvItem with an invalid name will output the invalid text string as red text in 2b)
b. If an IOException, ClassNotFoundException, or any other Exception occurs (for example, from attempting to load the array from a file that does not exist) the InvItem array will not change. The output in 2b) will be the message "load from file [filename] failed" in red text.
· The program should be implemented as a single file holding the public class InvTracker with the other classes (InvFrame and InvItem) not being public.
· The application should shut down when the window is closed out.
· Comments should be provided at the start of the class file (i.e., above the class definition) giving the class author’s name and the date the program was finished.
Use JPanel's setPreferredSize() method to shape your GUI window elements, allowing 5px for borders.