Question: A . Write the GUI with a textfield and implement the code so that the user can type into the textfield and see the text
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
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 P
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";
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
;
AND THIS
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
