JavaFX on the Web
In this section, we will learn about JavaFX on the Web and how to deploy our note-taking application there.
WebEngine
JavaFX provides a non-GUI component capable of loading HTML5 content, called the
WebEngine API (javafx.scene.web.WebEngine
). This API is basically an object instance of the WebEngine
class to be used to load a file containing HTML5 content. The HTML5 file could be loaded from a local file system, a web server, or from inside a JAR file.
When a file is loaded using a web engine object, a background thread is used to load the file content to not block the JavaFX application thread.
The following are two WebEngine
methods for loading HTML5 content:
- load(String URL)
- loadContent(String HTML)
WebView
JavaFX provides a GUI WebView
(javafx.scene.web.WebView
) node that can render HTML5 content onto the Scene graph. A WebView
node is basically a mini-browser that is capable of responding to web events and allows a developer to interact with the HTML5 content.
Because of...