class ClientGUI
This class represents the GUI for each client. It provides a control panel through which the user can interact with the system. It should support one or more conversations at the time.
attributes
client: Client
operation specifications
+ ClientGUI (client: Client)
-- constructor
pre: client not null
post: self.client = client
+ displayMsg (msg: String, nameMsgSender: String, code: Character)
-- displays a text message on the textdisplay
pre: code = ‘D’ -- for decrypted
or code = ‘E’ -- for encrypted
post: The msg has been added to the text display, with the name of the message
sender, nameMsgSender and labelled as ‘Decrypted’ or ‘Encrypted’.
+ displayConnectedUsers (connectedUsers: String[])
-- displays the list of connected users available for selection
pre: none
post: The list of connected users available for selection is displayed.
self is not included in the list.
Note:
You are free to choose the specific Java GUI component classes needed to implement the GUI. You are expected to apply the design principles of clarity and consistency to the GUI. You are at liberty to design the aesthetic “look and feel” of the interface, as long as you satisfy the class design specifications and the scenario requirements. The specifications for the GUI classes, ClientGUI and ControlPanel, have been left relatively loosely-defined to give you sufficient freedom for your design of the GUI. Add attributes and operations as you see fit. You are free to use either Java AWT or Java Swing packages to develop the GUI classes of the system.
In the design of this GUI class you have to think of the best interface for the user to handle more than one session with other users at same time. If you consider necessary, you can add a totally new class, as long as it is a GUI class and does not change the given specification. The change in the status of a session has to be updated and made visible somehow in the client GUI.
Hint: The ClientGUI class will need to implement the Java ActionListener interface. This allows it to respond to basic GUI events such as button presses and textfield entries. For example, if a button “Send Message” is pressed, the actionPerformed( ) method is called. You should implement this method so that it then calls the sendChatMessage( ) method of the Client class. Or when the “Accept” or “Reject” button is pressed, the sendCmd( ) method of the Client class should be called.