Introduction to Java FX
Introduction to Java FX
What is JavaFx?
● A Java library used to develop Desktop applications as well as Rich Internet
Applications (RIA).
● Can run on multiple platforms including Web, Mobile and Desktops.
● JavaFX is intended to replace swing in Java applications as a GUI framework.
● It provides more functionalities than swing.
● Like Swing, JavaFX also provides its own components and doesn't depend upon the
operating system.
● Provides a rich set of graphics and media API’s and it leverages the modern Graphical
Processing Unit through hardware accelerated graphics.
In short, Swing and JavaFX are both GUI toolkits for Java programs. Swing is the
old standard toolkit that features a bigger library of GUI elements and mature IDE
support. JavaFX is the newer standard with a smaller library, more consistent
updates, and consistent MVC support.
JavaFx Application Architecture
JavaFx application can be hierarchically divided into three components:
• Stage
• Scene
• Scene Graph (Nodes)
• Stage
• Stage in a JavaFX application is similar to the Frame in a Swing Application.
• It acts like a container for all the JavaFX objects.
• Primary Stage is created internally by the platform.
• Other stages can further be created by the application
• Scene
• Scene actually holds all the physical contents (nodes) of a JavaFX application.
• Scene class provides all the methods to deal with a scene object.
• Creating scene is necessary in order to visualize the contents on the stage.
• Scene Graph
• Scene Graph exists at the lowest level of the hierarchy.
• It can be seen as the collection of various nodes.
• A node is the element which is visualized on the stage.
• It can be any button, text box, layout, image, radio button, check box, etc.
Steps to create JavaFx Application
Step 1: Extend Application and override start()