You will be designing a chat room service.

Your program will consist of three main parts:

A.A GUI Controller this will have instructions, and buttons to start the server, to start each client, and to exit.

B.Client The Chat application for each user. Each client will run in its own thread. Start this class after the Server is running.

C.Server Manages the clients, checking their screen names and echo-printing their messages to the other clients. Start this class before the client.

Operation (what the user sees):

When the application starts, the user is presented with a window that has a list of instructions and three buttons: Start Server, Start Client, and Exit. see image.

The user starts the server first. If they attempt to start a client before a server, or to start more than one server, an error message is given.

Then the user starts a client. The user is asked for a screen name. If the name is already in use in this session an error message is given the user is re-asked for a screen name, or if the user selects Cancel, the user is re-asked for a screen name. The user can start multiple clients. see image.

When a user successfully enters a screen name, a window is shown where the user can type in a message. When the user enters a message, it is rebroadcast to all users. see image.

Specifications (what the programmer does):

1)Create a GUI Controller: this will have instructions, and buttons to start the server, to start each client, and to exit.

a)Instructions will be several labels

b)Start Server Button:

i)This button will have a mnemonic and a tooltip.

ii)When this button is selected, create a new ChatServerExec.

iii)Then call the ChatServerExec.startServer method with the port number as an argument if the server has not yet been created.

iv)The GUI controller will maintain a sentinel that specifies whether or not the server has been started yet, and display a JOptionPane message if it has.

c)Start Client Button:

i)This button will have a mnemonic and a tooltip.

ii)Each time the Start Client button is selected in the GUI, create a new ChatClientExec.

iii)Then call the ChatClientExec.startClient method with the port number as an argument

d)Exit Button:

i)This button will have a mnemonic and a tooltip.

ii)When selected, the server and any clients, along with the controller GUI, will close.

2)Client The Chat application for each user. The client will consist of an executive (ChatClientExec) and ChatClient classes.

a)Start ChatClientExec from the GUI after the Server is running.

b)ChatClientExec will create a new ChatClient and run it in its own thread.

c)The ChatClient process will create a new Stage, which will produce a separate GUI for each client.

d)The user will be asked to enter a screen name

e)When the screen name is accepted, the clients chat textbox will be enabled. When the user types into the textbox, the client will transmit the message to the server.

f)When the client receives messages from the server, it will be displayed in the clients textarea.

3)Server Manages the clients.

a)Maintain a list of screen names in use in this session and check new names for duplication.

b)Maintain a list of PrintWriter objects, and iterate through them to echo-print clients messages.

c)Start this class before the client.

4)Assumptions:

a)It is assumed that the GUI, the server, and clients will be run on the same computer.

b)It is assumed that synchronization of objects with locks or conditions will not be needed.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.