Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

need help with this java project: i have written code already that makes the gui

ID: 3813739 • Letter: N

Question

need help with this java project:

i have written code already that makes the gui, but i need help writing the ALert for the gui, and making the gui functional. my code is at the bottom!

directions;

Your task is to write a program that allows the user to experiment with different multithreaded sort algorithms. You should provide the user with an interface that looks very similar to the one shown below.

The user should be able to select the type of sorting algorithm to be used (selection, bubble, insertion, or quick), the size of the array to sort, the type of values to put in the array (already sorted in ascending order, sorted in reverse (descending) order, or random numbers between 0 and 99), and the number of values to sort in each thread. When the user clicks on the Go button, you should validate all of the input.

If the user has not provided required input or if the input is invalid (a negative input size, for example), you should display an alert dialog explaining the problem. Otherwise, collect all of the input and generate an appropriate array of integer values.

Then, “chunk” the array into the desired block size and pass each chunk to a thread that sorts the chunk into ascending order using the algorithm chosen by the user. When all of the chunks have been sorted, put the resulting sorted integer arrays into a queue. Then, poll two sorted chunks at a time from the queue, spawn a thread to merge them, and push the new merged array back onto the queue.

Repeat this process until there is only a single integer array in the queue. This array should now be sorted.

Display the sorted array to the console, and use an alert dialog to show the user how many milliseconds the sort process took.

example of gui:

example of alert from gui:

The output to the console is this: [0, 2, 2, 2, 3, 5, 5, 6, 7, 8, 9, 9, 13, 13, 15, 16, 17, 17, 19, 21, 23, 24, 25, 26, 27, 27, 32, 32, 32, 32, 33, 34, 35, 35, 36, 36, 37, 38, 38, 38, 39, 39, 41, 41, 43, 44, 45, 45, 46, 48, 48, 49, 50, 50, 53, 53, 54, 54, 54, 55, 55, 55, 60, 61, 62, 62, 63, 63, 63, 63, 65, 66, 68, 69, 69, 69, 72, 74, 74, 76, 76, 76, 78, 79, 80, 80, 81, 82, 82, 85, 85, 86, 87, 88, 89, 92, 95, 98, 98, 99]

And this alert dialog is displayed:

Your program will be graded according to this rubric (each item is worth one point):

• The program displays a user interface with the requested layout

• Pressing the Go button validates the user input and displays an alert dialog if necessary • The program correctly implements selection, bubble, insertion, and quick sort

• The program correctly implements the merge method

• The program spawns threads to sort chunks of the array with the requested size and using the requested algorithm

• The program spawns threads to merge the sorted chunks

• The program displays the number of milliseconds the sorting operation took via an alert dialog

my code:

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package project4practice;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;

/**
*
* @author
*/
public class Project4practice extends Application {

@Override
public void start(Stage primaryStage) {
BorderPane rootPane = new BorderPane();
GridPane gp = new GridPane();
//rootPane.setLeft(myList);
rootPane.setCenter(gp);
gp.setVgap(5);
gp.setHgap(5);

rootPane.prefWidth(700);
rootPane.prefHeight(400);

gp.prefWidth(400);
gp.prefHeight(400);
Label sort = new Label(" Sorting Algorithm ");
RadioButton selection = new RadioButton("selection ");
RadioButton bubble = new RadioButton("bubble ");
RadioButton insertion = new RadioButton("insertion");
RadioButton quick = new RadioButton("Quick ");

Label inputType = new Label(" Input Type ");
RadioButton sorted = new RadioButton("Already Sorted ");
RadioButton reverse = new RadioButton("Reverse ");
RadioButton random = new RadioButton("Random ");

Label inputSize = new Label(" Input Size: ");
TextField inputText = new TextField();
  
Label blockSize = new Label(" Block Size: ");
TextField block = new TextField();
Button go = new Button("Go ");

ToggleGroup tg = new ToggleGroup();
selection.setToggleGroup(tg);
bubble.setToggleGroup(tg);
insertion.setToggleGroup(tg);
quick.setToggleGroup(tg);
sorted.setToggleGroup(tg);
reverse.setToggleGroup(tg);
random.setToggleGroup(tg);

gp.add(sort,0,0);
gp.add(selection,0,1);
gp.add(bubble,0,2);
gp.add(insertion,0,3);
gp.add(quick,0,4);
gp.add(inputType,0,7);
gp.add(sorted,0,8);
gp.add(reverse,0,9);
gp.add(random,0,10);
gp.add(inputSize,0,12);
gp.add(inputText,1,12);
gp.add(blockSize,0,13);
gp.add(block,1,13);
gp.add(go,0,16);


Scene scene = new Scene(rootPane, 500, 350);

primaryStage.setTitle("Project 4");
primaryStage.setScene(scene);
primaryStage.show();
}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}

}

Project 4 Sorting Algorithm Selection Bubble Insertion Quick Input Type Already sorted Reverse order Random Input Size 100 Block Size 10 Go The output to the console is this:

Explanation / Answer

so, you want to disply the milliseconds to be shown on alert dialog box.

lets understand simple alert box.

So what you have to do is to, in your sorting function where you will perform various sorting,make that function to return milliseconds. Simply take that into a variable and put it into alert.setContentText().

Hope this helps.