How to do it...

  1. Let's first create a class with empty methods, which would represent the main application for launching the application as well as the JavaFX UI:
        public class BrowserDemo extends Application{
          public static void main(String[] args) {
            Application.launch(args);
          }
          @Override
          public void start(Stage stage) {
            //this will have all the JavaFX related code
          }
        }

In the subsequent steps, we will write all our code within the start(Stage stage) method.

  1. Let's create a javafx.scene.web.WebView component, which will render our web page. This has the required javafx.scene.web.WebEngine instance, which manages the loading of the web page:
        WebView webView = new WebView();
  1. Get the instance of javafx.scene.web.WebEngine used by webView ...

Get Java 11 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.