In this assignment, create a non-distributed Message Browser application in Java that utilizes the instructor provided Swing GUI. The Message Browser is a collection of Message objects. You are to create a Message class, that serializes/deserializes to/from a text file containing Json. The user interface provides the ability for browsing messages that are in the collection. In this case, the json file contains sample mail messages addressed to you. Your file should have atleast 4 messages.
The browser's constructor should read in the file initializing the message list (messageListJL) to include each message heading. Your message class should include a constructor to initialize a message object from a JSONObject, and another method to export a message object to a JSONObject. Be sure to include an appropriate initialization file with the solution you submit.
The user interface for client is provided in the example assign2WebDist.jar. It includes and Ant build file that will compile and execute a sample client. It also includes javadocs for the instructor provided MessageGui class. An example project that demonstrates serialziation to/from Json for both C++ and Java is provided in the example groupJson.jar.
Below is a view of the MessageGui. You are free to use this user-interface, or create your own. Should you create your own, you must use Java Swing, and incorporate the same controls and actions defined in this GUI see image.
In summary, create a stand-alone Message Client application, using Java. Your application should initialize a message library from a Json file, and have the ability to select, remove, and add (use the send text button) messages. Future assignments will enhance this solution by providing a Message Server and connecting the client to the server to replace the initialization json file.
Functionality. Here is an explanation of the functionality that your application should provide, together with a description of how users should interact with your GUI control logic.
Your application can assume that all users will only use the GUI as it is designed to be used. That is, you do not need to validate user inputs.
The fields on the right side of the Message Gui are used to compose messages. Message menu items (or buttons) are used to send a message. The Message actions the following:
To make future assignments easier, your solution should include two classes for the underlying application Model: Message, and MessageLibrary. These classes should have constructors for JSONObject, and a method to export and object's state to JSONObject. Your MessageLibrary class should also support the following methods:
// do not implement sendClearText in Assign2.
public boolean sendClearText(Message aMessage, String fromUser);
// do not implement sendCipher in Assign2.
public boolean sendCipher(Message aMessage, String fromUser);
// getMessageFromHeaders returns a string array of message headers being sent to toAUserName.
// Headers returned are of the form: (from user name @ server and message date)
// e.g., a message from J Buffett with header: Jimmy.Buffet Tue 18 Dec 5:32:29 2018
public String[] getMessageFromHeaders(String toAUserName);
// getMessage returns the Message having the corresponding header. Assume headers are unique.
// As above, the header has includes (from user name - server and message date)
public Message getMessage(String header);
// deletes the message having the header (from user name - server and message date)
public boolean deleteMessage(String header, String toAUserName);
Your application's model may implement these methods to receive new messages. As appropriate, add messages to the list. When the user selects the new message from the list, your program should display details of the message in the appropriate fields.