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 1(in three steps)
For part 1you need to setup the GUI and write most of the client-side code.
A.Write 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.
B.The user is supposed to be typing in a file name such as matrix1.txt.Now 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
matrices).This code can be copy pasted (with a few small modifications)from the
previous lab.
C.Pass 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 Server-side 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 1is completed successfully before
you move on.
Instructions for Part 2
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 it.No part 3.
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 multi-thread 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.io.IOException;
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.io.File;
import java.io.FileNotFoundException;
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()
{
super("Open File and Output Data Example");
//create enterField and register its listener
enterField =new JTextField("Enter file name here");
add(enterField,BorderLayout.NORTH);
displayArea =new JTextArea();
add(new JScrollPane(displayArea),BorderLayout.CENTER);
enterField.addActionListener(
new ActionListener(){
//get the file name specified by user
public void actionPerformed(ActionEvent event){
getFile(event.getActionCommand());
}
}
);
setSize(400,300); //set size of window
setVisible(true); //show window
}
//load document
private void getFile(String file_name)
{
file =new File(file_name);
try {
input =new Scanner(file);
}catch (FileNotFoundException e){
System.out.printf("%nError on file: %s (either enpty or wrong file format)%n%n",file);
e.printStackTrace();
System.exit(1);
}
String s;
while (input.hasNextLine()){
s =input.nextLine();
displayArea.append(s +"
");
}
}
}
AND
//Create and start a ReadWriteData object.
import javax.swing.JFrame;
public class ReadWriteDataTest
{
public static void main(String[]args)
{
ReadWriteData application =new ReadWriteData();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}

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 Programming Questions!