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

Mini Project Using JAVAFX Controls and Layouts

The document describes steps to create a mini JavaFX project using controls and layouts. It involves opening an editor, writing Java code to create UI elements like labels, text fields, checkboxes and adding them to a grid pane layout. It also describes compiling and running the project to display a registration form user interface.

Uploaded by

Alosius Gonzag
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)
584 views

Mini Project Using JAVAFX Controls and Layouts

The document describes steps to create a mini JavaFX project using controls and layouts. It involves opening an editor, writing Java code to create UI elements like labels, text fields, checkboxes and adding them to a grid pane layout. It also describes compiling and running the project to display a registration form user interface.

Uploaded by

Alosius Gonzag
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/ 5

Mini Project using JAVAFX controls and layouts

Aim
To Develop a Mini Project using various JavaFX controls, Layouts and Menus.

Algorithm
Step 1: Open the programming editor and use the different javaFX UI features to type the Java code.

Step 2: After writing the Java code, we must save the filename.java source code.

Step 3: Get the JavaFX package from the relevant website.

Step 4: After downloading the JavaFX package, we must specify the PATH_TO_FX environmental

variable, whose value is the location of the javaFX /lib folder, which is typically E:\javafx-sdk-17.0.2\lib.

Step 5: After completing the aforementioned process, open a command prompt and use the following

command to compile the relevant JavaFX program.

javac -d . --module-path E:\javafx-sdk-17.0.2\lib --add-modules javafx.controls,javafx.fxml package

name.RegistrationApplication.java

Step 6: The aforementioned step will assist in creating the Java class file in the previously specified package

format.

Step 7: Finally, we need to use the following command to launch this JavaFX application.

java --module-path E:\javafx-sdk-17.0.2\lib --add-modules javafx.controls,javafx.fxml packagename.

RegistrationApplication

Step 8: Stop the Program


JavaFX Mini Project Program

package application;
import javafx.application.Application; import javafx.collections.*;
import javafx.geometry.Insets; import javafx.geometry.Pos;
import javafx.scene.image.*;
import javafx.scene.Scene; import javafx.scene.control.*;
import javafx.scene.layout.*; import javafx.scene.text.Text;
import javafx.stage.Stage;

public class RegistrationFormApplication1 extends Application


{
@Override
public void start(Stage stage)
{
//Label for name
Text nameLabel = new Text("Name");
//Text field for name
TextField nameText = new TextField();
//Label for date of birth
Text dobLabel = new Text("Date of birth");
//date picker to choose date
DatePicker datePicker = new DatePicker();
//Label for gender
Text genderLabel = new Text("gender");
//Toggle group of radio buttons
ToggleGroup groupGender = new ToggleGroup(); RadioButton maleRadio = new RadioButton("male");
maleRadio.setToggleGroup(groupGender);
RadioButton femaleRadio = new RadioButton("female"); femaleRadio.setToggleGroup(groupGender);
//Label for reservation
Text reservationLabel = new Text("Reservation");
//Toggle button for reservation
ToggleButton yes = new ToggleButton("Yes"); ToggleButton no = new ToggleButton("No");
ToggleGroup groupReservation = new ToggleGroup(); yes.setToggleGroup(groupReservation);
no.setToggleGroup(groupReservation);
//Label for technologies known
Text technologiesLabel = new Text("Technologies Known");
//check box for education
CheckBox javaCheckBox = new CheckBox("Java"); javaCheckBox.setIndeterminate(false);
//check box for education
CheckBox dotnetCheckBox = new CheckBox("DotNet"); javaCheckBox.setIndeterminate(false);
//Label for education
Text educationLabel = new Text("Educational qualification");
//list View for educational qualification
ObservableList<String> names = FXCollections.observableArrayList( "B.E","M.E","BBA","MCA",
"MBA", "Vocational", "M.TECH", "Mphil",
"Phd");
ListView<String> educationListView = new ListView<String>(names);
educationListView.setMaxSize(100, 100);
educationListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
Label interest=new Label("Area of Interest"); ComboBox AoI=new ComboBox();
AoI.getItems().addAll("Android App. Dev.", "IoS App. Dev.", "FUll Stack Dev.", "Azure FrmWork",
"AWS", "Web Dev.", "Ui/Ux Design");
AoI.setVisibleRowCount(3);
//Label for location
Text locationLabel = new Text("location");
//Choice box for location
ChoiceBox locationchoiceBox = new ChoiceBox(); locationchoiceBox.getItems().addAll
("Hyderabad", "Chennai", "Delhi", "Mumbai", "Vishakhapatnam");
//Label for register
Button buttonRegister = new Button("Register");
//Creating a Grid Pane
GridPane gridPane = new GridPane();
//Setting size for the pane gridPane.setMinSize(500, 500);
//Setting the padding
gridPane.setPadding(new Insets(10, 10, 10, 10));
//Setting the vertical and horizontal gaps between the columns gridPane.setVgap(5);
gridPane.setHgap(5);
//Setting the Grid alignment gridPane.setAlignment(Pos.CENTER);
//Arranging all the nodes in the grid gridPane.add(nameLabel, 0, 0);
gridPane.add(nameText, 1, 0);
gridPane.add(dobLabel, 0, 1);
gridPane.add(datePicker, 1, 1);
gridPane.add(genderLabel, 0, 2);
gridPane.add(maleRadio, 1, 2);
gridPane.add(femaleRadio, 2, 2);
gridPane.add(reservationLabel, 0, 3);
gridPane.add(yes, 1, 3);
gridPane.add(no, 2, 3);
gridPane.add(technologiesLabel, 0, 4);
gridPane.add(javaCheckBox, 1, 4);
gridPane.add(dotnetCheckBox, 2, 4);
gridPane.add(educationLabel, 0, 5);
gridPane.add(educationListView, 1, 5);
gridPane.add(interest,0,6); gridPane.add(AoI,1,6);
gridPane.add(locationLabel, 0, 7);
gridPane.add(locationchoiceBox, 1, 7);
gridPane.add(buttonRegister, 2, 8);
Scene scene = new Scene(gridPane);
stage.setScene(scene);
stage.show();
//Setting title to the Stage stage.setTitle("Registration Form");
//Adding scene to the stage stage.setScene(scene);
//Displaying the contents of the stage stage.show();
}
public static void main(String[] args)
{
launch(args);
}
}
Compile Procedure

JavaFX Mini Project Output

Result
Thus, the javaFX Mini project was successfully created and output was verified.

You might also like