Question: Can someone help me with this java assignment, I provided all my code, some will be in the comments because its too long. import java.awt.Color;

Can someone help me with this java assignment, I provided all my code, some will be in the comments because its too long. Can someone help me with this java assignment, I provided all mycode, some will be in the comments because its too long. importjava.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.GroupLayout; import javax.swing.JButton; import javax.swing.JLabel; importjavax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.LayoutStyle; import javax.swing.WindowConstants; public class ServerGUIextends javax.swing.JFrame { // Variables declaration - do not modify private JButtonbtnClose; private JButton btnListen; private JButton btnQuit; private JButton btnStop; private JScrollPane

import java.awt.Color;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.GroupLayout;

import javax.swing.JButton;

import javax.swing.JLabel;

import javax.swing.JScrollPane;

import javax.swing.JTextArea;

import javax.swing.JTextField;

import javax.swing.LayoutStyle;

import javax.swing.WindowConstants;

public class ServerGUI extends javax.swing.JFrame {

// Variables declaration - do not modify

private JButton btnClose;

private JButton btnListen;

private JButton btnQuit;

private JButton btnStop;

private JScrollPane jScrollPane1;

private JLabel lblCliendID;

private JLabel lblServerData;

private JLabel lblServerURL;

private JLabel lblStatus;

private JLabel lblStatusConnectDisconnect;

private JTextArea txtAreaClientData1;

private JTextField txtClientID;

private JTextField txtClientID1;

// End of variables declaration

public ServerGUI(String title) {

this.setTitle("Server"); //set the title

lblStatusConnectDisconnect = new JLabel();

lblCliendID = new JLabel();

btnQuit = new JButton();

btnClose = new JButton();

btnStop = new JButton();

lblStatus = new JLabel();

lblServerURL = new JLabel();

lblServerData = new JLabel();

txtClientID = new JTextField();

txtClientID1 = new JTextField();

jScrollPane1 = new JScrollPane();

txtAreaClientData1 = new JTextArea();

btnListen = new JButton();

setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

lblStatusConnectDisconnect.setBackground(Color.RED);

lblStatusConnectDisconnect.setText("Not Connected");

lblCliendID.setText("Port #");

btnQuit.setText("Quit");

btnQuit.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent evt) {

btnQuitActionPerformed(evt);

}

});

btnClose.setText("Close");

btnClose.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent evt) {

btnCloseActionPerformed(evt);

}

});

btnStop.setText("Stop");

btnStop.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent evt) {

btnStopActionPerformed(evt);

}

});

btnListen.setText("Listen");

btnListen.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

btnListenActionPerformed(evt);

}

});

lblStatus.setText("Status");

lblServerURL.setText("Time Out");

lblServerData.setText("Server Log Below");

txtAreaClientData1.setColumns(20);

txtAreaClientData1.setRows(5);

jScrollPane1.setViewportView(txtAreaClientData1);

(30 points) Lab 2 Out utilizes the GUI implemented in lablout (within the constructor of the ServerGUclass) as shown below: Server Status: Not Connected Port # Timeout Server Log Below Listen Close top Quit The purpose of the GUI is to control the ChatServer class (see ChatServer section below for a complete description) You will need to add the following private data field to the SererGl class: private Cbatsecvec, server This server datafield should be instantiated within the Secvecu constructor using its default constructor If the user presses the Listen JButton without the port# or timeout entered (both should be entered), display "Port Number'timeout not entered before pressing Listen" in the Server Log TextArea If the user presses the Close or Stop JButton before the server is successfully started (i.e., the Listen button has not been pressed), display "Server not currently started in the Server Log TextArea The ServeGlll applications shuts down (and the GUI closes) if the user presses the Quit JButton at any time. Once the port# and timeout has been successfully entered into the GUI, pressing the Listen utton results in the following 1. 2. Invoke the listen service method on the ChatServer private data field (serve). Change the status Label to display "Listening" and color it Green (this should be done in the severStarted hook method of the ChatServer class). Status: Listening Port# 8300 Timeout Server Log Below Listen Close Stop Quit The message "Server Started" should be displayed in the log TextArea by the serverStarted hook method of the ChatServer class(see ChatServer section below) Pressing the Stop JButton (assuming Listen button has been previously pressed) will result in the following steps: 1. Invoke the stonListenine service method on the ChatServer private data field (server). 2. Change the status Label to display "Stopped" and color it Red (this should be done in the method). 3. The message Server Stopped Accepting New Clients-Press Listen to Start Accepting New Clients" should be displayed in the log TextArea by the serverStepped hook method of the ChatServer class (see ChatServersection below) The stop service method prevents the Server from accepting any new clients. The previously accepted servers are however processed as before. example of the GUI atter pressing Stop Server is shown below Status: Stopped Port 8300 Timeout Server Log Below r Started Stopped Acceping New Clients -Press Listen to Start Accepng New Listen Close Stop Quit Pressing the Close Button (assuming Listen button has been previously pressed) will result in he following steps: 1. Invoke the close service method on the ChatServer private data field sv 2. Change the status Label to display "Close" and color it Red (the statusaelshould be changed in the ChatServers serverClosed method). 3. The message Server and all current clients are closed - Press Listen to Restart" should be displayed in the log TextArea by the serverClosed hook method of the ChatServer class (see ChatServersection below) The close service method closes all clients currently connected to the server. The Server will eed to press "Listen" to restart and begin accepting clients again. An example of the GUI after ressing "Close" JBtton is shown below: Note: serverClosed and serverStoned methods are both invoked when the close method of the erver is invoked. Server Status: Close Port # 8300 Timeout 500 Server Log Below Server Started Server Stopped Accepting New Clients-Press Listen to Start Accepting New Clie and all ourrent clients are closed Press Listen to Restart Listen CloseStopQuit ChatServer Implement a class named ChatServer (must extend AbstractServer)that implements the Server portion of the Chat System. The hatSerxer should declare the following private data fields: private 3TextAcea log; //Corresponds t2TextArea of secvecsu private abel status; //Corresponds to the abel of SecxerUI These 2 private data fields are needed when updating the SecvecgUl from within the Hook methods of the ChatServer class Implement the following methods for the ShatServer class public Chatserver) Constructor for ChatServer class. public void setLog TextArea log Setter for JTextAxea originally declared and implemented in the SerexGlllclass. This should be invoked within the Constructor of the ServerGUclass public void setstatus Label status) Setter for JLabel status area declared and implemented in the ServerGull.class. This should be inoked within the Constructor of the ServerGll class public void bandloint(object arge, Sonoestigntlient argl) Slot method from AbstractServer class. For now, just display the following message to the Console: "Message from Client Received" public void isteningException(Throwable exception) Hook method that is invoked whenever an Exception occurs while the ChatServer is in the process of accepting a client. Display the message associated with the parameter exception in the log TextAcea of the SeryerGUL whenever this method is invoked. This method will be invoked when a non-Java client attempts to connect to the ChatServer For example, trying to connect a Web Browser to the ChatServeresults in the following display: Server Status: Exception Occurred when Listening port # Server Log Below r Started Excepton invalid stream header: 47455420 s Listen to Restart Server Listen Close S1op Quit Also display the informational message that the user should press "Listen" again to restart the server. The status JLabel should also be set to "Exception Occurred when Listening" colored to public void secxecstacted.) Hook method for ChatServer. Display the message "Server Started" to the log TextArea Also sets the JLabel status to Listening and is colored green. (See example shown previously) public void Hook method for ChatServer. Display the message Server Stopped Accepting New Clients Press Listen to Start Accepting New Clients" to the log JTextArea. Also sets the uabel status to Stopped and is colored red. (See example shown previously) public void serverclosed) Hook method for ChatServer. Display the message "Server and all current clients are closed Press Listen to Restart" to the log Close and is colored red. (See example shown previously Also sets the Label status to public void sieat Hook method for ChatSerxez. For now, just display the message "Client connected" to the log ITextArea onested&SonnestienteClient client) (30 points) Lab 2 Out utilizes the GUI implemented in lablout (within the constructor of the ServerGUclass) as shown below: Server Status: Not Connected Port # Timeout Server Log Below Listen Close top Quit The purpose of the GUI is to control the ChatServer class (see ChatServer section below for a complete description) You will need to add the following private data field to the SererGl class: private Cbatsecvec, server This server datafield should be instantiated within the Secvecu constructor using its default constructor If the user presses the Listen JButton without the port# or timeout entered (both should be entered), display "Port Number'timeout not entered before pressing Listen" in the Server Log TextArea If the user presses the Close or Stop JButton before the server is successfully started (i.e., the Listen button has not been pressed), display "Server not currently started in the Server Log TextArea The ServeGlll applications shuts down (and the GUI closes) if the user presses the Quit JButton at any time. Once the port# and timeout has been successfully entered into the GUI, pressing the Listen utton results in the following 1. 2. Invoke the listen service method on the ChatServer private data field (serve). Change the status Label to display "Listening" and color it Green (this should be done in the severStarted hook method of the ChatServer class). Status: Listening Port# 8300 Timeout Server Log Below Listen Close Stop Quit The message "Server Started" should be displayed in the log TextArea by the serverStarted hook method of the ChatServer class(see ChatServer section below) Pressing the Stop JButton (assuming Listen button has been previously pressed) will result in the following steps: 1. Invoke the stonListenine service method on the ChatServer private data field (server). 2. Change the status Label to display "Stopped" and color it Red (this should be done in the method). 3. The message Server Stopped Accepting New Clients-Press Listen to Start Accepting New Clients" should be displayed in the log TextArea by the serverStepped hook method of the ChatServer class (see ChatServersection below) The stop service method prevents the Server from accepting any new clients. The previously accepted servers are however processed as before. example of the GUI atter pressing Stop Server is shown below Status: Stopped Port 8300 Timeout Server Log Below r Started Stopped Acceping New Clients -Press Listen to Start Accepng New Listen Close Stop Quit Pressing the Close Button (assuming Listen button has been previously pressed) will result in he following steps: 1. Invoke the close service method on the ChatServer private data field sv 2. Change the status Label to display "Close" and color it Red (the statusaelshould be changed in the ChatServers serverClosed method). 3. The message Server and all current clients are closed - Press Listen to Restart" should be displayed in the log TextArea by the serverClosed hook method of the ChatServer class (see ChatServersection below) The close service method closes all clients currently connected to the server. The Server will eed to press "Listen" to restart and begin accepting clients again. An example of the GUI after ressing "Close" JBtton is shown below: Note: serverClosed and serverStoned methods are both invoked when the close method of the erver is invoked. Server Status: Close Port # 8300 Timeout 500 Server Log Below Server Started Server Stopped Accepting New Clients-Press Listen to Start Accepting New Clie and all ourrent clients are closed Press Listen to Restart Listen CloseStopQuit ChatServer Implement a class named ChatServer (must extend AbstractServer)that implements the Server portion of the Chat System. The hatSerxer should declare the following private data fields: private 3TextAcea log; //Corresponds t2TextArea of secvecsu private abel status; //Corresponds to the abel of SecxerUI These 2 private data fields are needed when updating the SecvecgUl from within the Hook methods of the ChatServer class Implement the following methods for the ShatServer class public Chatserver) Constructor for ChatServer class. public void setLog TextArea log Setter for JTextAxea originally declared and implemented in the SerexGlllclass. This should be invoked within the Constructor of the ServerGUclass public void setstatus Label status) Setter for JLabel status area declared and implemented in the ServerGull.class. This should be inoked within the Constructor of the ServerGll class public void bandloint(object arge, Sonoestigntlient argl) Slot method from AbstractServer class. For now, just display the following message to the Console: "Message from Client Received" public void isteningException(Throwable exception) Hook method that is invoked whenever an Exception occurs while the ChatServer is in the process of accepting a client. Display the message associated with the parameter exception in the log TextAcea of the SeryerGUL whenever this method is invoked. This method will be invoked when a non-Java client attempts to connect to the ChatServer For example, trying to connect a Web Browser to the ChatServeresults in the following display: Server Status: Exception Occurred when Listening port # Server Log Below r Started Excepton invalid stream header: 47455420 s Listen to Restart Server Listen Close S1op Quit Also display the informational message that the user should press "Listen" again to restart the server. The status JLabel should also be set to "Exception Occurred when Listening" colored to public void secxecstacted.) Hook method for ChatServer. Display the message "Server Started" to the log TextArea Also sets the JLabel status to Listening and is colored green. (See example shown previously) public void Hook method for ChatServer. Display the message Server Stopped Accepting New Clients Press Listen to Start Accepting New Clients" to the log JTextArea. Also sets the uabel status to Stopped and is colored red. (See example shown previously) public void serverclosed) Hook method for ChatServer. Display the message "Server and all current clients are closed Press Listen to Restart" to the log Close and is colored red. (See example shown previously Also sets the Label status to public void sieat Hook method for ChatSerxez. For now, just display the message "Client connected" to the log ITextArea onested&SonnestienteClient client)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!