- JavaFX Tutorial
- JavaFX - Home
- JavaFX - Overview
- JavaFX - Environment
- JavaFX - Architecture
- JavaFX - Application
- JavaFX - 2D Shapes
- JavaFX - Text
- JavaFX - Effects
- JavaFX - Transformations
- JavaFX - Animations
- JavaFX - Colors
- JavaFX - Images
- JavaFX - 3D Shapes
- JavaFX - Event Handling
- JavaFX - UI Controls
- JavaFX - Charts
- JavaFX - Layout Panes
- JavaFX - CSS
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
JavaFX - Architecture
JavaFX provides a complete API with a rich set of classes and interfaces to build GUI applications with rich graphics. The important packages of this API are −
javafx.animation − Contains classes to add transition based animations such as fill, fade, rotate, scale and translation, to the JavaFX nodes.
javafx.application − Contains a set of classes responsible for the JavaFX application life cycle.
javafx.css − Contains classes to add CSSâ€“like styling to JavaFX GUI applications.
javafx.event − Contains classes and interfaces to deliver and handle JavaFX events.
javafx.geometry − Contains classes to define 2D objects and perform operations on them.
javafx.stage − This package holds the top level container classes for JavaFX application.
javafx.scene − This package provides classes and interfaces to support the scene graph. In addition, it also provides sub-packages such as canvas, chart, control, effect, image, input, layout, media, paint, shape, text, transform, web, etc. There are several components that support this rich API of JavaFX.
The following illustration shows the architecture of JavaFX API. Here you can see the components that support JavaFX API.
In JavaFX, the GUI Applications were coded using a Scene Graph. A Scene Graph is the starting point of the construction of the GUI Application. It holds the (GUI) application primitives that are termed as nodes.
A node is a visual/graphical object and it may include −
Geometrical (Graphical) objects − (2D and 3D) such as circle, rectangle, polygon, etc.
UI controls − such as Button, Checkbox, Choice box, Text Area, etc.
Containers − (layout panes) such as Border Pane, Grid Pane, Flow Pane, etc.
Media elements − such as audio, video and image objects.
In general, a collection of nodes makes a scene graph. All these nodes are arranged in a hierarchical order as shown below.
Each node in the scene graph has a single parent, and the node which does not contain any parents is known as the root node.
In the same way, every node has one or more children, and the node without children is termed as leaf node; a node with children is termed as a branch node.
A node instance can be added to a scene graph only once. The nodes of a scene graph can have Effects, Opacity, Transforms, Event Handlers, Event Handlers, Application Specific States.
Prism is a high performance hardwareâ€“accelerated graphical pipeline that is used to render the graphics in JavaFX. It can render both 2-D and 3-D graphics.
To render graphics, a Prism uses −
- DirectX 9 on Windows XP and Vista.
- DirectX 11 on Windows 7.
- OpenGL on Mac and Linux, Embedded Systems.
In case the hardware support for graphics on the system is not sufficient, then Prism uses the software render path to process the graphics.
When used with a supported Graphic Card or GPU, it offers smoother graphics. Just in case the system does not support a graphic card, then Prism defaults to the software rendering stack (either of the above two).
GWT (Glass Windowing Toolkit)
As the name suggests, GWT provides services to manage Windows, Timers, Surfaces and Event Queues. GWT connects the JavaFX Platform to the Native Operating System.
It is an abstraction over the low-level components of Prism, Glass, Media Engine, and Web Engine. It ties Prism and GWT together and makes them available to JavaFX.
Using WebView, you can −
- Render HTML content from local or remote URL.
- Support history and provide Back and Forward navigation.
- Reload the content.
- Apply effects to the web component.
- Edit the HTML content.
- Handle events.
In general, using WebView, you can control web content from Java.
The JavaFX media engine is based on an open-source engine known as a Streamer. This media engine supports the playback of video and audio content.
The JavaFX media engine provides support for audio for the following file formats −
The package javafx.scene.media contains the classes and interfaces to provide media functionality in JavaFX. It is provided in the form of three components, which are −
Media Object − This represents a media file
Media Player − To play media content.
Media View − To display media.