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

Java Please add comments so I follow and understand. Thanks Create a graphical u

ID: 3664240 • Letter: J

Question

Java Please add comments so I follow and understand. Thanks

Create a graphical user interface for it using JavaFX. In addition to the native JavaFX, also use Controls- FX (http://fxexperience.com/controlsfx/). The user should start the program and be able to open a file using a file selector. The file should be presented in the user interface in one text field and the errors in another. Use ControlsFX to make your application better, we like you to experiment with it and use the controls you see fit to make your application better or nicer to look at.

Explanation / Answer

/*

* To change this template, choose Tools | Templates

* and open the template in the editor.

*/

package javafxguiexample;

/**

*

* @author HARE KRISHNA

*/

import javafx.application.Application;

import javafx.event.ActionEvent;

import javafx.event.eventHandler;

import javafx.scene.Scene;

import javafx.scene.control.Button;

import javafx.scene.layout.StackPane;

import javafx.stage.Stage;

public class JavafxGUIExample {

    /**

     * @param args the command line arguments

     */

    public static void main(String[] args) {

        // TODO code application logic here

        launch(args);

    }

    @Override

    public void start(Stage primaryStage) {

        primaryStage.setTitle("Hello World!");

        Button btn = new Button();

        btn.setText("Say 'Hello World'");

        btn.setOnAction(new EventHandler<ActionEvent>() {

            @Override

            public void handle(ActionEvent event) {

                System.out.println("Hello World!");

    }

});

StackPane root = new StackPane();

root.getChildren().add(btn);

primaryStage.setScene(new Scene(root, 300, 250));

//Here using grid pane,for creating text fields ,in the grid

GridPane grid = new GridPane();

grid.setAlignment(Pos.CENTER);

grid.setHgap(10);

grid.setVgap(10);

grid.setPadding(new Insets(25, 25, 25, 25));

//Scene class and Intialize object

Scene scene = new Scene(grid, 300, 275);

primaryStage.setScene(scene);

//new TextField Based on our requirement

Text scenetitle = new Text("Welcome");

scenetitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));

grid.add(scenetitle, 0, 0, 2, 1);

// label declaration

Label userName = new Label("User Name:");

grid.add(userName, 0, 1);   

//TextField declaration

TextField userTextField = new TextField();

grid.add(userTextField, 1, 1);

//label for Wrong data display here

Label pw = new Label("Wrong data display:");

grid.add(pw, 0, 2);

//create 2nd textfield for wrong data store

TextField tfBox = new TextField ();

grid.add(tBfox, 1, 2);

//for file selector

FileChooser fileChooser = new FileChooser();

fileChooser.setTitle(“open Resource File”);

fileChooser.showOpenDialog(stage);

primaryStage.show();

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote