Question: Instructions for Part 1 ( in three steps ) For part 1 you need to setup the GUI and write most of the client -
Instructions for Part in three steps For part you need to setup the GUI and write most of the clientside 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 matrixtxt 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 Serverside command prompt Modify the code to match the requirements
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";
addenterField BorderLayout.NORTH;
displayArea new JTextArea;
addnew JScrollPanedisplayArea BorderLayout.CENTER;
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 formatnn file;
eprintStackTrace;
System.exit;
String s;
while inputhasNextLine
s input.nextLine;
displayArea.appends
;
MATRIX
AND USE THIS AS WELL
Create and start a ReadWriteData object.
import javax.swing.JFrame;
public class ReadWriteDataTest
public static void mainString args
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
