Question

In: Computer Science

Develop a JavaFX GUI application called Registration that implements a user interface for registering for a...

Develop a JavaFX GUI application called Registration that implements a user interface for registering for a web site. The application should have labeled text fields for the Full Name, User Name, Password, Student Id, and a TextAreafor About Me. Include a button labeled Send. When the Send button is clicked, your program should print the contents of all fields (with labels) to standard output using println()statements.

Solutions

Expert Solution

Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. If not, PLEASE let me know before you rate, I’ll help you fix whatever issues. Thanks


//Registration.java

import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;

public class Registration extends Application {

    @Override
    public void start(Stage primaryStage) {

        //creating a GridPane to contain UI components
        GridPane root = new GridPane();
        //setting padding
        root.setPadding(new Insets(10));
        //and spacing betweeen components
        root.setHgap(10);
        root.setVgap(10);

        //initializing each label and text field
        Label nameLbl = new Label("Full Name: ");
        TextField nameTxt = new TextField();

        Label usernameLbl = new Label("Username: ");
        TextField usernameTxt = new TextField();

        Label passLbl = new Label("Password: ");
        //using a PasswordField for password, so the contents are hidden when typed.
        TextField passTxt = new PasswordField();

        Label idLbl = new Label("Student ID: ");
        TextField idTxt = new TextField();

        Label aboutLbl = new Label("About Me: ");
        TextArea aboutTxt = new TextArea();

        Button sendBtn = new Button("Send");

        //adding each component to the grid pane in proper column and row
        root.add(nameLbl, 0, 0); //column 0, row 0
        root.add(nameTxt, 1, 0);//column 1, row 0

        root.add(usernameLbl, 0, 1);
        root.add(usernameTxt, 1, 1);

        root.add(passLbl, 0, 2);
        root.add(passTxt, 1, 2);

        root.add(idLbl, 0, 3);
        root.add(idTxt, 1, 3);

        root.add(aboutLbl, 0, 4);
        //adding text area to column 0, row 5 occupying 2 columns width
        root.add(aboutTxt, 0, 5, 2, 1);
        
        root.add(sendBtn, 0, 6);
        
        //adding event listener for button
        sendBtn.setOnAction(e -> {
            //fetching contents
            String name = nameTxt.getText();
            String username = usernameTxt.getText();
            String pass = passTxt.getText();
            String id = idTxt.getText();
            String abtme = aboutTxt.getText();
            
            //printing to console.
            System.out.println("Name: " + name);
            System.out.println("Username: " + username);
            System.out.println("Password: " + pass);
            System.out.println("ID: " + id);
            System.out.println("About Me:\n" + abtme);
        });

        //setting up and displaying a scene
        Scene scene = new Scene(root);
        primaryStage.setScene(scene);
        primaryStage.setTitle("Registration");
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }

}

/*OUTPUT*/


Related Solutions

*In JAVA and JavaFX please!! CSE1322 – Assignment 8 – GUI General User Interface Assignment 8...
*In JAVA and JavaFX please!! CSE1322 – Assignment 8 – GUI General User Interface Assignment 8 Objectives • Build a GUI application similar to a calculator. • Create an application that acts as a simple calculator. Create buttons for 0-9 and a text field that displays the concatenation of the current digits as they are clicked. • Add buttons for operators “+”, “-“, “*”, and “/”. • Add a final button for “=” that calculates the computed value with the...
For this assignment, you will develop working examples of a graphical user interface (GUI) and event...
For this assignment, you will develop working examples of a graphical user interface (GUI) and event handling and that demonstrate the following: Working code with screenshots of a Python GUI application that includes 5 design widgets of your choosing Working code with screenshots of event handling in Python based on 3 events of your choosing Be sure to include a brief narrative of your code where you explain what the code is doing. Documentation Guidelines: Use good programming style (e.g.,...
Develop a GUI to get unique names from the user.
in JAVADevelop a GUI to get unique names from the user. . In the first frame use a label ("Name") a textfield and 2 buttons (ext' and 'inished") . In the second frame there should be a list and a scrollpane as the components . Use the components on the first frame to get the name value from the user. . When the user enters a name make sure it is not empty and has no spaces and dicks the next' button, reset the...
JAVA code Create a new class called BetterDiGraph that implements the EditableDiGraph interface See the interface...
JAVA code Create a new class called BetterDiGraph that implements the EditableDiGraph interface See the interface below for details. EditableDigraph below: import java.util.NoSuchElementException; /** * Implements an editable graph with sparse vertex support. * * */ public interface EditableDiGraph {    /** * Adds an edge between two vertices, v and w. If vertices do not exist, * adds them first. * * @param v source vertex * @param w destination vertex */ void addEdge(int v, int w); /** *...
The purpose of this problem is to use graphic user interface (GUI) to interactively store grades...
The purpose of this problem is to use graphic user interface (GUI) to interactively store grades in a text file, rather than adding them manually to a script. Follow these steps to complete the program: Step 1. Use a question dialog box and ask the user “Do you want to run this Program?” with two options for “yes” and “no”. If the user’s answer is “yes”, go to the next step, otherwise, go to Step 6. Step 2. Create a...
Use the below info to create a java program A GUI interface to ensure a user...
Use the below info to create a java program A GUI interface to ensure a user is old enough to play a game. Properly formatted prompts to input name, address, phone number, and age. Remember that name, address, phone number, etc. can be broken out in additional fields. Refer to the tutorial from this week’s Reading Assignment Multiple vs. Single Field Capture for Phone Number Form Input for help with this. Instructions to ensure that the information is displayed back...
Using matlab: Build a graphical user interface (GUI) the will read the two corners of a...
Using matlab: Build a graphical user interface (GUI) the will read the two corners of a rectangle (from the GUI interface) and show the following: A plot of the rectangle (you should have display for it) Show the centroid (the center of the rectangle) on the graph. Calculate the area and the circumference of the triangle (you need to write a function for that). The interface should have at least the following: Four textboxes to read the ( 2 for...
Create a JavaFX application that lets the user enter the food charge for a meal at...
Create a JavaFX application that lets the user enter the food charge for a meal at a restaurant. For example, if $20 is entered as a food charge for a meal then $3.6 should be displayed for the tip, $1.4 should be displayed for sales tax, and $25 should be displayed as a total of all three amounts. Modification 1: create a text box (not a pop up) for the user to enter a percent tip (don't just hardcode it...
Write a JavaFX application that presents two buttons and a number (initially 50) to the user....
Write a JavaFX application that presents two buttons and a number (initially 50) to the user. Label the buttons Increment and Decrement. When the increment button is pushed, increment the displayed value. Likewise, decrement the value when the decrement button is pushed. This has to use Java.Fx and not Java.Awt
irst, you will complete a class called HazMath (in the HazMath.java file) that implements the interface...
irst, you will complete a class called HazMath (in the HazMath.java file) that implements the interface Mathematical (in the Mathematical.java file). These should have the following definitions: public boolean isPrime(int n) You cannot change the signature for the method. This method is similar to the ones we've discussed in the lab and will return true or false depending on if the passed in integer values is prime or not, respectively. Return false if the invoker passes in a number less...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT