Question: JAVA CHAT PROGRAM/NETWORKING HELP I'm not sure how to work on this assignment, however I have written for my previous assignment The links are at
JAVA CHAT PROGRAM/NETWORKING HELP
I'm not sure how to work on this assignment, however I have written for my previous assignment "The links are at the end of this paragraph" Please follow the instructions as described below, I have included a sample look of how the GUI should look like. As described below the final project should have 4 files (client, server, gui, thread). I will definitly make sure to give positive feedback to whoever that helps me figure out this assignment. It would help me A LOT if you follow the instructions as below so then I can go through and learn how each section was written
Sample GUI look: https://ibb.co/jmqs6G
Codes from my previous assignment that has Client/Server side (thought this might help): Client: http://textuploader.com/djbg6 Server: http://textuploader.com/djbgl
Actual Assignment:
Write both a Client and a Server chat program in Java. This chat program should contain a GUI
interface for both Client and Server. The program will need to allow both the Server and the
Client to send/receive as many messages as they wish without the need to take turns.
The Client Program:
The GUI Frame title will be: Client Program
The Client will connect to the Server program using IP 127.0.0.1 and port 18888.
When the Client is connected, the Server will automatically send You are Connected and the
Client will display this message in a separate area of the GUI (I used a JTextArea control).
The Client user will enter a string from the keyboard into the GUI (I used a JTextField), press the
return key and the string will be sent to the Server. The string will be preceded by the words
Client Said: . This message will also appear in the Clients GUI. The Client does not need to
wait for the Server. It can send as many messages as it chooses and at any time it wants.
When a message is received from the Server it will be displayed in a separate area of the GUI (I
used a JTextArea control).
The conversation will continue until the user enters the word quit (from either the Server or the
Client). After the word quit has been entered or received an appropriate message should be
displayed in a separate area of the GUI (I used a JTextArea control).
The Server Program:
The GUI Frame title will be: Server Program
The Server will begin listening on port 18888.
As soon as the program begins the Server will display a message Waiting on a Connection.
As soon as the client connects to the Server. The Server will send the following message to the
Client. You are Now Connected. The Server will also display a message Client Connected
in the GUI. (I used the JTextArea control).
The conversation will continue (just like the Client description above). The Server will precede
the messages with Server Said: .
Program Design for the Client Side
The Client.java will contain the main (point on entry).
The main will have one line of code, (call the constructor of the Client class).
You will have three classes for your Client.
The main Client class. (SmithClient)
A GUI class. (SmithGUI)
A Thread subclass. (SmithThread)
Structure of the Client Class (Client)
Purpose of the Class: To connect to the Server and start the program.
Client() // the constructor
This method will
request a connection to the server
call the constructor of the GUI class
assign the title to the GUI object
send the socket object to the GUI
main(String [] args)
This method will only call the constructor of the Client class
Structure of the GUI Class (GUI)
Purpose of the Class:
The user interface:
To allow the user to enter data
To display data to the user
private data members
MyThread object
Socket object
Others as needed
GUI() // constructor
This method will create all of the GUI controls
actionPerformed(ActionEvent e)
This method will get the data from the JTextField and call the
sendAMessage method of the GUI class
displayMessage(String s)
This method will add the string s to the bottom of the JTextArea. If s is the word
quit, it will close all resources.
sendAMessage(String s)
This method will send the string s to the internet. If s is the word quit, it will
close all resources.
Other Methods as needed
Note: You must use this class to run both the Client and Server.
Structure of the Thread class
Purpose of the Class: Read data from the internet and send it to the GUI class.
There must be a private data member of Boolean type (you might want to call it
connected). It will determine if the two are connected.
Others as needed.
MyThread(Scanner s, GUI g) // the constructor.
This method will save these values into other private data member variables.
Note: this class knows nothing about a socket object
run()
This method will read data from the socket Scanner object and send it to the GUI.
It will continuously read from the scanner while (connected is true).
changeConnected
This method will be used to change the value of your Boolean connected object.
Note: This class must be a subclass of the Thread class. This class will not contain any
references to the keyboard input. Also the only occurrence of System.out will be
in the catch block. You must use this class to run both the Client and Server.
Program Design for the Server Side
The design of the server side is practically the same except at the beginning.
In the beginning the server will wait for a connection and send the You are Connected
message. After that it is the same as the Client side.
Object names: The names of the objects in this documents are used as example names. They are
meant to help describe the purpose of the assignment and are not required in your project
submission.
Do not use interclasses or put multiple class in one .java file.
Do no use packages. Remove all of these package statements.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
