Question: List of classes that you will write: ServerStart contains the main method to instantiate and start up the Server. Server the Server class code ClientStart
List of classes that you will write:
ServerStart contains the main method to instantiate and start up the Server.
Server the Server class code
ClientStart contains the main method to instantiate and start up the Client.
Client the Client class code, including the GUI
ThreadOperation You wont write this one because you should already have
written it for the previous lab. If the previous lab went well then you will be able to use
this without any modification.
Instructions for Part in three steps
For part you need to setup the GUI and write most of the clientside code.
AWrite the GUI with a textfield and implement the code so that the user can type into the
textfield and see the text they typed in printed on the command prompt.
BThe user is supposed to be typing in a file name such as matrixtxtNow modify
your code so that the text the user typed in is used as the filename that is opened. Open
the file and read in the data number of rows, number of columns, and the two integer
matricesThis code can be copy pasted with a few small modificationsfrom the
previous lab.
CPass the two matrices to the Server and write the server so that it displaysthe matrices
on its end either through a Server GUI or on the Serverside command prompt
DO NOT perform any matrix calculations on the Server side yet. Dont create threads or sum
quadrants or calculate indexes. I want to make sure Part is completed successfully before
you move on
Instructions for Part
Integrate the concurrent programming code from the previous lab into the server code,
perform the concurrent sum of the matrix quadrants, then transmit the solution matrix back to
the client. The client should then display the solution in a textarea.
Make sure that you also implement the TERMINATE command to close the connection. Make
sure that the Server continues running, waiting for future clients to connect.
Thats itNo part
Compilation and Execution
I will test your program as follows:
javac java
for the Server
java ServerStart
for the Client
java ClientStart
USING Ask user to enter the matrix file
not covered:
Perform the multithread computation and gather the result
Display the result on the JScrollPane
Demo: Display the content of the matrix from the file opened by the previous step
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.ioIOException;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import java.util.Scanner;
import java.ioFile;
import java.ioFileNotFoundException;
public class ReadWriteData extends JFrame
private JTextField enterField; JTextField to enter the matrix file name
private JTextArea displayArea; JTextAreato display the computation result
private File file;
private Scanner input;
set up GUI
public ReadWriteData
superOpen File and Output Data Example";
create enterField and register its listener
enterField new JTextFieldEnter file name here";
addenterFieldBorderLayoutNORTH;
displayArea new JTextArea;
addnew JScrollPanedisplayAreaBorderLayoutCENTER;
enterField.addActionListener
new ActionListener
get the file name specified by user
public void actionPerformedActionEvent event
getFileeventgetActionCommand;
;
setSize; set size of window
setVisibletrue; show window
load document
private void getFileString filename
file new Filefilename;
try
input new Scannerfile;
catch FileNotFoundException e
System.out.printfnError on file: s either enpty or wrong file formatnnfile;
eprintStackTrace;
System.exit;
String s;
while inputhasNextLine
s inputnextLine;
displayArea.appends
;
AND
Create and start a ReadWriteData object.
import javax.swing.JFrame;
public class ReadWriteDataTest
public static void mainStringargs
ReadWriteData application new ReadWriteData;
application.setDefaultCloseOperationJFrameEXITONCLOSE;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
