Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Name : Hardik Parmar

SE 5
Roll No : 38

Experiment No.14
Date of Performance: 5/12/21
Date of Submission: 12/12/21

Program Documentatio Timely Viva Experime Teacher Signatur e


formation/ n (02) Submissio Answe nt with date
Execution / n (03) r (03) Marks(15)
Ethical
practices(0
7)
Aim : Study of JavaFX.
Lab Outcome No. : 2.ITL304.6
Lab Outcome : Develop Graphical User Interface by exploring JavaFX
framework based on MVC architecture.

THEORY:

JavaFX tutorial provides basic and advanced concepts of JavaFX. Our JavaFX
tutorial is designed for beginners and professionals.

JavaFX is a Java library that is used to develop Desktop applications as well


as Rich Internet Applications (RIA). The applications built in JavaFX, can run
on m Components

JavaFX has works with four main components from which others derive, these
are: Stage, Scene, Node and Layout.

Stage

Is the central element, acting as a container for all the scenes. Following the
analogy with a Theater, is the space where everything happens inside.

Scene

Is a smaller element that that contains a group of nodes (GUI elements) and
contains them.

Node

Are the elements that compose a scene (buttons, text-boxes, labels, etc…). It is
possible and usually the case, nodes have children nodes under their hierarchy,
having the ability to nest/be nested.

Layout

As the name says, it is responsible for defining how the nodes and elements are
shown on the screen.ultiple platforms including Web, Mobile and Desktops.

PROBLEM STATEMENT:
Write a Java program to design a Login Form using JavaFX Controls.
PROGRAM:
import javafx.application.Application;

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.TextField; import

javafx.scene.layout.StackPane; import

javafx.scene.layout.VBox; import

javafx.stage.Stage;

public class App extends Application

{ private StackPane root = new StackPane();

private Stage stage;

@Override

public void init() {

Button button = new Button("OPEN");

VBox vBox = new VBox();

vBox.setSpacing(8);

vBox.setPadding(new Insets(10,10,10,10));

vBox.getChildren().addAll( new

Label("Your Username"),
new TextField(),

new Label("Your Password"),

new PasswordField(), new

Button("LOGIN"));

root.getChildren().addAll(vBox);

button.setOnAction(actionEvent-> {

if(stage!=null)

{ stage.requestFocus();

return;

stage = new Stage();

StackPane stackPane = new StackPane();

stage.setScene(new Scene(stackPane, 200,200));

stage.show();

});

@Override

public void start(Stage primaryStage)

{ Scene scene = new Scene(root,400,600);

primaryStage.setScene(scene);

primaryStage.show();

primaryStage.setTitle("Login Example JavaFX");

primaryStage.setAlwaysOnTop(true);
}

public static void main(String[] args)

{ launch(args);

OUTPUT:

CONCLUSION:

Hence, in this experiment we studied the concept of JavaFX and developed a


login form using JavaFX components.

You might also like