Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

17.13 - Combine files GUI I successfully wrote code for the scenario below. I would like someone from your team to rewrite the code using

17.13 - Combine files GUI

I successfully wrote code for the scenario below. I would like someone from your team to rewrite the code using a different approach. This will allow me to see how someone else may go about coding this program and ultimately coming out with the same results. Please code using Java and verify it will run in a Java IDE. My code can be found below. Thanks.

*17.12 (Combine files) Write a utility program that combines the files together into anew file using the following command:

java Exercise17_12 SourceFile1 . . . SourceFilen TargetFile

The command combines SourceFile1, . . . , and SourceFilen into TargetFile.

17.13 (Combine files GUI) Rewrite Exercise 17.12 with a GUI, as shown in

Figure below:

image text in transcribed

This is my code for the program. It runs successfully, no issues. Please re-code using a different approach so I can compare and contrast a different ways to write the same program.

package Chapter_17; import javafx.application.Application; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.layout.BorderPane; import javafx.scene.layout.GridPane; import javafx.stage.Stage; import java.io.*; /** * (Combine files GUI) * Rewrite Exercise 17.12 with a GUI, as shown in Figure 17.21b. * Created by Luiz Arantes Sa on 11/30/14. */ public class Exercise_13 extends Application { @Override public void start(Stage primaryStage) throws Exception { FileCombinerPane pane = new FileCombinerPane(); primaryStage.setScene(new Scene(pane)); primaryStage.setTitle("File Combiner"); primaryStage.show(); } private class FileCombinerPane extends BorderPane { TextField tfFilename; TextField tfNumOfDivision; Button btnSplit; FileCombinerPane() { tfFilename = new TextField(); tfNumOfDivision = new TextField(); btnSplit = new Button("Combine Files"); btnSplit.setOnAction(e -> combineFiles()); Label lblDescription = new Label( "If the base file is named temp.txt with 3 peices, " + "temp.txt.1, temp.txt.2, temp.txt.3 are combined into temp.txt " + "Enter absolute path if file is not in working directory..."); Label lblFilename = new Label("Base Filename:"); Label lblNumOfDivision = new Label("Number Of Files:"); // Format gridPane and nodes GridPane gridPane = new GridPane(); gridPane.add(lblDescription, 0, 0,2,1); gridPane.addRow(1, lblFilename, tfFilename); gridPane.addRow(2, lblNumOfDivision, tfNumOfDivision); gridPane.setHgap(10); gridPane.setVgap(10); gridPane.setPadding(new Insets(20)); GridPane.setFillWidth(tfNumOfDivision, false); tfNumOfDivision.setPrefColumnCount(4); setCenter(gridPane); setBottom(btnSplit); setAlignment(btnSplit, Pos.CENTER); setPadding(new Insets(10)); } public void combineFiles() { File[] splitFiles = new File[Integer.parseInt(tfNumOfDivision.getText())]; File targetFile = new File(tfFilename.getText()); // Verify if src files exists for (int i = 0; i Exerdsei7-13 If the base file is named temp.txt with three pieces, temp.txt.1, temp.bt 2, and temp.bt.3 are combined irto temp.tt. Enter a fle: Specify the numbei of s"eller files: temp.txt Start

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago