0% found this document useful (0 votes)
10 views

Assignment 4

The document contains code for a JavaFX registration page application. It creates a registration form with labels and input fields for name, email, phone, password, country, gender, language and about section. It also includes a registration button that displays an alert message on successful registration. The form fields are added to a grid pane and displayed in a scene on the primary application stage.

Uploaded by

Huzaifa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Assignment 4

The document contains code for a JavaFX registration page application. It creates a registration form with labels and input fields for name, email, phone, password, country, gender, language and about section. It also includes a registration button that displays an alert message on successful registration. The form fields are added to a grid pane and displayed in a scene on the primary application stage.

Uploaded by

Huzaifa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Huzaifa Arshad 61353

import
javafx.application.Applicat
ion;
import
javafx.geometry.Insets;
import javafx.scene.Scene;
import
javafx.scene.control.*;
import
javafx.scene.layout.GridPan
e;
import javafx.stage.Stage;
public class RegistrationPage
extends Application {

@Override
public void start(Stage
primaryStage) {

primaryStage.setTitle("Regi
stration Page");

GridPane grid = new


GridPane();
grid.setPadding(new
Insets(20, 20, 20, 20));
grid.setVgap(10);
grid.setHgap(10);

Label nameLabel = new


Label("Name:");
Label emailLabel = new
Label("Email:");
Label phoneLabel = new
Label("Phone:");
Label passwordLabel =
new Label("Password:");
Label confirmLabel =
new Label("Confirm
Password:");
Label countryLabel =
new Label("Country:");
Label genderLabel = new
Label("Gender:");
Label languageLabel =
new Label("Language:");
Label aboutYouLabel =
new Label("About You:");

TextField nameField =
new TextField();
TextField emailField =
new TextField();
TextField phoneField =
new TextField();
PasswordField
passwordField = new
PasswordField();
PasswordField
confirmField = new
PasswordField();

ChoiceBox<String>
countryChoice = new
ChoiceBox<>();

countryChoice.getItems().ad
dAll("Country 1", "Country 2",
"Country 3");
ChoiceBox<String>
genderChoice = new
ChoiceBox<>();

genderChoice.getItems().add
All("Male", "Female",
"Other");
ChoiceBox<String>
languageChoice = new
ChoiceBox<>();

languageChoice.getItems().a
ddAll("English", "Spanish",
"French");

TextArea
aboutYouTextArea = new
TextArea();

Button registerButton
= new Button("Register");

registerButton.setOnAction(
e -> {

Alert alert = new


Alert(Alert.AlertType.INFOR
MATION);

alert.setTitle("Registratio
n Successful");

alert.setHeaderText(null);

alert.setContentText("Regis
tration Successfully");

alert.showAndWait();
});

grid.add(nameLabel, 0,
0);
grid.add(nameField, 1,
0);
grid.add(emailLabel,
0, 1);
grid.add(emailField,
1, 1);
grid.add(phoneLabel,
0, 2);
grid.add(phoneField,
1, 2);

grid.add(passwordLabel, 0,
3);

grid.add(passwordField, 1,
3);
grid.add(confirmLabel,
0, 4);
grid.add(confirmField,
1, 4);
grid.add(countryLabel,
0, 5);

grid.add(countryChoice, 1,
5);
grid.add(genderLabel,
0, 6);
grid.add(genderChoice,
1, 6);

grid.add(languageLabel, 0,
7);

grid.add(languageChoice, 1,
7);

grid.add(aboutYouLabel, 0,
8);

grid.add(aboutYouTextArea, 1,
8);

grid.add(registerButton, 1,
9);

Scene scene = new


Scene(grid, 400, 400);

primaryStage.setScene(scene
);
primaryStage.show();
}

public static void


main(String[] args) {
launch(args);
}
}

You might also like