Table of contents
1.
Introduction
2.
JavaFX public API
3.
Scene Graph
4.
Graphics Engine
4.1.
Prism
4.2.
Quantum Tool Kit
5.
GWT
6.
WebView
7.
Media Engine
8.
Frequently Asked Questions
8.1.
Which component provides graphics support to the scene graph?
8.2.
Which component or the level of the JavaFX stack acts as an interface between JavaFX and the native operating system?
8.3.
Which software is used by Prism on MacOS?
9.
Conclusion
Last Updated: Mar 27, 2024

JavaFX Architecture

Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

JavaFX is one of the Java libraries which is freely available and is used to create next-generation client application platforms for desktop, mobile, and other embedded systems which are built on java. JavaFX aims to replace swing in Java applications as a GUI framework, though it provides more functionalities than swing. JavaFX provides its components and is not dependent on the operating system. It is lightweight and hardware-accelerated. JavaFX architecture has many built-in components like JavaFX public API, Scene Graph, Prism, and many more. All these components help in developing rich GUI applications with advanced properties.

JavaFX public API

There are multiple layers in JavaFX architecture, out of which the top layer contains JavaFX public API. This layer contains all the necessary classes and interfaces required to run a fully-featured JavaFX application. The packages which are provided by this API are listed below.

Scene Graph

When we start constructing a JavaFX application, we always start with the Scene Graph API, which is the starting point of constructing a JavaFX application. It is a hierarchical tree in which all the graphical elements of the user interface are the nodes. Each node has its own id, volume, and style. Nodes in the scene graph can have only one parent tho they can have either zero or multiple children. The scene graph is also used in event handling. Whatever implementation that is performed by the user on the scene graph is applied to the nodes in it. There are various packages that allow the user to create and generate various transformations and animations in JavaFX applications, some of those packages are javafx.scene.input, javafx.scene.shape, javafax.scene.media, etc. 

Each node in the Scene graph has the following:

  • Geometrical Objects: Includes all the 2D as well as 3D shapes such as rectangles, circles, and polygons.
  • UI Controls: Node contains various UI components like text area, etc.
  • Containers: There are some layout panes available in the JavaFX containers, such as border, grid, and flow.

Graphics Engine

The graphics engine provides graphics support for 2D as well as 3D graphics to the scene graph. If the graphics hardware on the system cannot support the hardware-accelerated rendering, then the graphics engine also provides the software rendering. There are two graphics accelerated pipelines in the JavaFX, which are as follows:

Prism

It is a high-performance hardware-accelerated graphical pipeline that is used to render graphics in JavaFX. It is capable of rendering both 2D as well as 3D graphics. In order to render graphics, a prism uses different software depending on the operating system, which is:

  • DirectX 9 is used on Windows XP & Vista
  • DirectX 11 is used on Windows 7
  • OpenGL is used on Mac & Linux
     

Prism uses the software to render the path to process the graphics if the hardware support for graphics on the system is insufficient. It also smoothers the graphics when used along with a GPU, and if the system does not support a graphic card, then the Prism defaults to the software rendering stack.

Quantum Tool Kit

It is like an abstraction over the low-level components of Prism, Glass, Web Engine & Media Engine. It combines the prism and glass windowing toolkit and makes it available to the upper layer of the stack.

GWT

GWT stands for Glass Windowing Toolkit. It is the lowest or the last level of the JavaFX stack. It is platform dependent and acts as an interface between the JavaFX and the native operating system. Glass Windowing Toolkit is responsible for handling all the operating system's services, such as the windows, event queues, and timers. It also provides a connection between the JavaFX application and the operating system for further communication.

WebView

JavaFX allows the user to embed the HTML content into a scene graph and webview is the JavaFX component used to process this content. WebView uses a technology called Web Kit, which is basically an internal open-source web browser engine. WebView supports various web technologies such as HTML5, CSS, JavaScript, DOM, etc.

Using WebView, a user can do the following:

  • Render HTML content from either a local or remote URL.
  • Provides back and forth navigation along with history support.
  • Allows the user to apply effects to the web component as well as edit the HTML content
  • Allows the user to execute javascript commands and also handle various events.

Media Engine

It provides all the audio-video playback and media files in the JavaFX application. It is dependent upon the G streamer. The javafx.scene.media provides all the classes and interfaces which are required for media function in JavaFX. JavaFX media engine supports various audio formats such as MP3, WAV, AIFF, and video formats like FLC. 

It provides the functionality with the help of three components:

  • Media Object: Represents a media file.
  • Media Player: Used to play media content.
  • Media View: Used to display media.

Frequently Asked Questions

Which component provides graphics support to the scene graph?

The graphic engine provides support to the scene graph.
 

Which component or the level of the JavaFX stack acts as an interface between JavaFX and the native operating system?

The Glass windowing toolkit, which is the lowest layer of the JavaFX stack, acts as an interface between JavaFX and the native operating system.
 

Which software is used by Prism on MacOS?

The Prism uses the OpenGL software on macOS.

Conclusion

In this article, we have extensively discussed the Architecture of JavaFX.

After reading about the Architecture of JavaFX, are you not feeling excited to read/explore more articles on Java libraries? Don't worry; Coding Ninjas has you covered. To learn about the top 10 Java librariesthe top open-source librariesand how to make UI that stands out using java libraries.  

If you wish to enhance your skills in Data Structures and AlgorithmsCompetitive ProgrammingJavaScript, etc., you should check out our Guided path column at Coding Ninjas Studio. We at Coding Ninjas Studio organize many contests in which you can participate. You can also prepare for the contests and test your coding skills by giving the mock test series available. In case you have just started the learning process, and your dream is to crack major tech giants like Amazon, Microsoft, etc., then you should check out the most frequently asked problems and the interview experiences of your seniors that will surely help you in landing a job in your dream company. 

Do upvote if you find the blogs helpful.

Happy Learning!

Live masterclass