Embedding HTML
To add HTML to JavaFX is easy. All you have to do is to use the javafx.scene.web.WebView
class, which provides a window where the added HTML is rendered similar to how it happens in a browser. The WebView
class uses WebKit, the open source browser engine, and thus supports full browsing functionality.
Like all other JavaFX components, the WebView
class extends the Node
class and can be treated in the Java code as such. In addition, it has its own properties and methods that allow adjusting the browser window to the encompassing application by setting the window size (maximum, minimum, and preferred height and width), font scale, zoom rate, adding CSS, enabling the context (right-click) menu, and similar. The getEngine()
method returns a javafx.scene.web.WebEngine
object associated with it. It provides the ability to load HTML pages, navigate them, apply different styles to the loaded pages, access their browsing history and the document model, and execute JavaScript...